diff --git a/lib/lib-dynamodb/src/commands/marshallInput.spec.ts b/lib/lib-dynamodb/src/commands/marshallInput.spec.ts index c6df6f96e4e43..5a407cd2c9613 100644 --- a/lib/lib-dynamodb/src/commands/marshallInput.spec.ts +++ b/lib/lib-dynamodb/src/commands/marshallInput.spec.ts @@ -10,6 +10,13 @@ describe("marshallInput and processObj", () => { } ); }); + + it("should ignore function properties", () => { + const input = { Items: [() => {}, 1, "test"] }; + const inputKeyNodes = { Items: null }; + const output = { Items: { L: [{ N: "1" }, { S: "test" }] } }; + expect(marshallInput(input, inputKeyNodes, { convertTopLevelContainer: true })).toEqual(output); + }); }); describe("marshallInput for commands", () => { diff --git a/lib/lib-dynamodb/src/commands/utils.spec.ts b/lib/lib-dynamodb/src/commands/utils.spec.ts index dad1cfa939f8d..8ec4332df9a0e 100644 --- a/lib/lib-dynamodb/src/commands/utils.spec.ts +++ b/lib/lib-dynamodb/src/commands/utils.spec.ts @@ -19,6 +19,12 @@ describe("utils", () => { nativeAttrObj: { Item1: nativeAttrValue(1), Item2: nativeAttrValue(2), ...notAttrValue }, attrObj: { Item1: attrValue(1), Item2: attrValue(2), ...notAttrValue }, }, + { + testName: "object with function property", + keyNodes: { Item: {} }, + nativeAttrObj: { Item: { id: 1, func: () => {} }, ...notAttrValue }, + attrObj: { Item: { id: { N: "1" } }, ...notAttrValue }, + }, { testName: "array", keyNodes: { Items: { "*": {} } }, diff --git a/packages/util-dynamodb/src/marshall.spec.ts b/packages/util-dynamodb/src/marshall.spec.ts index ea16c3cb2d030..cc16845e62459 100644 --- a/packages/util-dynamodb/src/marshall.spec.ts +++ b/packages/util-dynamodb/src/marshall.spec.ts @@ -62,4 +62,12 @@ describe("marshall", () => { expect(convertToAttr).toHaveBeenCalledTimes(1); expect(convertToAttr).toHaveBeenCalledWith(input, undefined); }); + + it("with function properties in input object", () => { + const input = { a: "A", b: "B", func: () => {}, func2: () => {} }; + // const expectedOutput = { a: { M: mockOutput }, b: { M: mockOutput } }; + expect(marshall(input)).toEqual(mockOutput); + expect(convertToAttr).toHaveBeenCalledTimes(1); + expect(convertToAttr).toHaveBeenCalledWith(input, undefined); + }); });