Skip to content

Commit

Permalink
Test for returning all propertie, not just updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SethO committed Oct 28, 2023
1 parent be1d242 commit 0f025ac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/updatePartial.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,29 @@ describe('When updating an item', () => {
await expect(updateAction()).rejects.toThrow(`${item.revision}`);
});
});

describe('with a subset of properties', () => {
it('should return the entire object with the updated properties', async () => {
// ARRANGE
const item = createTestKeyValueItem();
const key = await insertHashKeyItem(item);
testKeys.push(key);
const itemWithoutField1: any = { ...item };
delete itemWithoutField1.field1;
const newMap = { field2: 'affirmative' };
itemWithoutField1.map1 = newMap;
const repo = new KeyValueRepository({
tableName: TableName,
keyName: KeyName,
documentClient,
});

// ACT
const result = await repo.updatePartial(itemWithoutField1);

// ASSERT
expect(result.map1).toEqual(newMap);
expect(result.field1).toEqual(item.field1);
});
});
});

0 comments on commit 0f025ac

Please sign in to comment.