Skip to content

Commit

Permalink
feat(amplify-appsync-simulator): use mapper.map to convert to JavaString
Browse files Browse the repository at this point in the history
  • Loading branch information
alichherawalla committed Jul 2, 2021
1 parent 5c9172a commit 80d9fba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { JavaArray } from './../../../velocity/value-mapper/array';
import { JavaMap } from '../../../velocity/value-mapper/map';
import { toJavaString } from '../../../velocity/value-mapper/string';
import { JavaString } from '../../../velocity/value-mapper/string';
import { map as mapper } from '../../../velocity/value-mapper/mapper';

describe('JavaMap', () => {
let identityMapper = jest.fn().mockImplementation(val => val);
Expand Down Expand Up @@ -71,7 +72,7 @@ describe('JavaMap', () => {
it('keySet returns a JavaArray with each element of type JavaString', () => {
const obj = { foo: 'Foo Value', bar: 'Bar Value' };
const map = new JavaMap(obj, identityMapper);
expect(map.keySet()).toEqual(new JavaArray([toJavaString('foo'), toJavaString('bar')], toJavaString));
expect(map.keySet()).toEqual(new JavaArray([new JavaString('foo'), new JavaString('bar')], mapper));
});

it('put', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { JavaArray } from './array';
import { toJavaString } from './string';
import { toJSON } from './to-json';
import { map } from './mapper';

export class JavaMap {
private map: Map<string, any>;
Expand Down Expand Up @@ -57,7 +58,7 @@ export class JavaMap {
}

keySet() {
return new JavaArray(Array.from(this.map.keys()).map(toJavaString), toJavaString);
return map(Array.from(this.map.keys()));
}

put(key, value) {
Expand Down

0 comments on commit 80d9fba

Please sign in to comment.