Skip to content

Commit

Permalink
test(lib-dynamodb): adding additional test cases for function properties
Browse files Browse the repository at this point in the history
  • Loading branch information
siddsriv committed Jan 24, 2024
1 parent a9246f3 commit 90018d5
Showing 1 changed file with 87 additions and 1 deletion.
88 changes: 87 additions & 1 deletion lib/lib-dynamodb/src/commands/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,94 @@ describe("object with function property", () => {
const keyNodes = { Item: {} };
const nativeAttrObj = { Item: { id: 1, func: () => {} }, ...notAttrValue };
const attrObj = { Item: { id: { N: "1" } }, ...notAttrValue };

it(marshallInput.name, () => {
expect(marshallInput(nativeAttrObj, keyNodes, { convertTopLevelContainer: true })).toEqual(attrObj);
});

// List of functions
const listOfFunctions = { Item: { id: 1, funcs: [() => {}, () => {}] }, ...notAttrValue };
it(marshallInput.name, () => {
expect(
marshallInput(listOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
).toEqual(attrObj);
});

// Nested list of functions
const nestedListOfFunctions = {
Item: {
id: 1,
funcs: [
[() => {}, () => {}],
[() => {}, () => {}],
],
},
...notAttrValue,
};
it(marshallInput.name, () => {
expect(
marshallInput(nestedListOfFunctions, keyNodes, {
convertTopLevelContainer: true,
convertClassInstanceToMap: true,
})
).toEqual(attrObj);
});

// Nested list of functions 3 levels down
const nestedListOfFunctions3Levels = {
Item: {
id: 1,
funcs: [
[
[() => {}, () => {}],
[() => {}, () => {}],
],
[
[() => {}, () => {}],
[() => {}, () => {}],
],
],
},
...notAttrValue,
};
it(marshallInput.name, () => {
expect(
marshallInput(nestedListOfFunctions3Levels, keyNodes, {
convertTopLevelContainer: true,
convertClassInstanceToMap: true,
})
).toEqual(attrObj);
});

// Map of functions
const mapOfFunctions = { Item: { id: 1, funcs: { func1: () => {}, func2: () => {} } }, ...notAttrValue };
it(marshallInput.name, () => {
expect(
marshallInput(mapOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
).toEqual(attrObj);
});

// Map of list of functions
const mapOfListOfFunctions = {
Item: { id: 1, funcs: { funcList1: [() => {}, () => {}], funcList2: [() => {}, () => {}] } },
...notAttrValue,
};
it(marshallInput.name, () => {
expect(
marshallInput(mapOfListOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
).toEqual(attrObj);
});

// Nested map of functions
const mapOfMapOfFunctions = {
Item: {
id: 1,
funcs: { funcMap1: { func1: () => {}, func2: () => {} }, funcMap2: { func1: () => {}, func2: () => {} } },
},
...notAttrValue,
};
it(marshallInput.name, () => {
expect(
marshallInput(mapOfMapOfFunctions, keyNodes, { convertTopLevelContainer: true, convertClassInstanceToMap: true })
).toEqual(attrObj);
});
});

0 comments on commit 90018d5

Please sign in to comment.