diff --git a/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts b/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts index 2cfbbcb56e9..60e5fee115f 100644 --- a/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts +++ b/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts @@ -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); @@ -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'); diff --git a/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts b/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts index d075fa022b0..184f91f0d36 100644 --- a/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts +++ b/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts @@ -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) {