Skip to content

Commit

Permalink
fix(amplify-appsync-simulator): string functions not called on items … (
Browse files Browse the repository at this point in the history
aws-amplify#7636)

* fix(amplify-appsync-simulator): string functions not called on items of JavaArray<string> in the resolvers

* feat(amplify-appsync-simulator): added toJavaString that accepts a string and returns a JavaString

* feat(amplify-appsync-simulator): map.keySet returns an a JavaArray with elements of type JavaString

* feat(amplify-appsync-simulator): using this.mapper in map.keySet
  • Loading branch information
alichherawalla authored and xo28122000 committed Jul 12, 2021
1 parent 1e167b2 commit 483bbc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { JavaArray } from './../../../velocity/value-mapper/array';
import { JavaMap } from '../../../velocity/value-mapper/map';
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 @@ -66,6 +69,12 @@ describe('JavaMap', () => {
expect(map.keySet().toJSON()).toEqual(['foo', 'bar']);
});

it('keySet returns a JavaArray with each element of type JavaString', () => {
const obj = { foo: 'Foo Value', bar: 'Bar Value' };
const map = new JavaMap(obj, mapper);
expect(map.keySet()).toEqual(new JavaArray([new JavaString('foo'), new JavaString('bar')], mapper));
});

it('put', () => {
const map = new JavaMap({}, identityMapper);
map.put('foo', 'Foo Value');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class JavaMap {
}

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

put(key, value) {
Expand Down

0 comments on commit 483bbc1

Please sign in to comment.