Skip to content

Commit 90018d5

Browse files
committed
test(lib-dynamodb): adding additional test cases for function properties
1 parent a9246f3 commit 90018d5

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

lib/lib-dynamodb/src/commands/utils.spec.ts

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,94 @@ describe("object with function property", () => {
152152
const keyNodes = { Item: {} };
153153
const nativeAttrObj = { Item: { id: 1, func: () => {} }, ...notAttrValue };
154154
const attrObj = { Item: { id: { N: "1" } }, ...notAttrValue };
155-
156155
it(marshallInput.name, () => {
157156
expect(marshallInput(nativeAttrObj, keyNodes, { convertTopLevelContainer: true })).toEqual(attrObj);
158157
});
158+
159+
// List of functions
160+
const listOfFunctions = { Item: { id: 1, funcs: [() => {}, () => {}] }, ...notAttrValue };
161+
it(marshallInput.name, () => {
162+
expect(
163+
marshallInput(listOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
164+
).toEqual(attrObj);
165+
});
166+
167+
// Nested list of functions
168+
const nestedListOfFunctions = {
169+
Item: {
170+
id: 1,
171+
funcs: [
172+
[() => {}, () => {}],
173+
[() => {}, () => {}],
174+
],
175+
},
176+
...notAttrValue,
177+
};
178+
it(marshallInput.name, () => {
179+
expect(
180+
marshallInput(nestedListOfFunctions, keyNodes, {
181+
convertTopLevelContainer: true,
182+
convertClassInstanceToMap: true,
183+
})
184+
).toEqual(attrObj);
185+
});
186+
187+
// Nested list of functions 3 levels down
188+
const nestedListOfFunctions3Levels = {
189+
Item: {
190+
id: 1,
191+
funcs: [
192+
[
193+
[() => {}, () => {}],
194+
[() => {}, () => {}],
195+
],
196+
[
197+
[() => {}, () => {}],
198+
[() => {}, () => {}],
199+
],
200+
],
201+
},
202+
...notAttrValue,
203+
};
204+
it(marshallInput.name, () => {
205+
expect(
206+
marshallInput(nestedListOfFunctions3Levels, keyNodes, {
207+
convertTopLevelContainer: true,
208+
convertClassInstanceToMap: true,
209+
})
210+
).toEqual(attrObj);
211+
});
212+
213+
// Map of functions
214+
const mapOfFunctions = { Item: { id: 1, funcs: { func1: () => {}, func2: () => {} } }, ...notAttrValue };
215+
it(marshallInput.name, () => {
216+
expect(
217+
marshallInput(mapOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
218+
).toEqual(attrObj);
219+
});
220+
221+
// Map of list of functions
222+
const mapOfListOfFunctions = {
223+
Item: { id: 1, funcs: { funcList1: [() => {}, () => {}], funcList2: [() => {}, () => {}] } },
224+
...notAttrValue,
225+
};
226+
it(marshallInput.name, () => {
227+
expect(
228+
marshallInput(mapOfListOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
229+
).toEqual(attrObj);
230+
});
231+
232+
// Nested map of functions
233+
const mapOfMapOfFunctions = {
234+
Item: {
235+
id: 1,
236+
funcs: { funcMap1: { func1: () => {}, func2: () => {} }, funcMap2: { func1: () => {}, func2: () => {} } },
237+
},
238+
...notAttrValue,
239+
};
240+
it(marshallInput.name, () => {
241+
expect(
242+
marshallInput(mapOfMapOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
243+
).toEqual(attrObj);
244+
});
159245
});

0 commit comments

Comments
 (0)