Skip to content

Commit 61f4229

Browse files
committed
add test for dynamodb-toolbox#103
1 parent 6dfcd45 commit 61f4229

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/__tests__/entity.update.unit.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ const TestEntity3 = new Entity({
7676
attributes: {
7777
email: { type: 'string', partitionKey: true },
7878
test: { type: 'string', required: true },
79-
test2: { type: 'string', required: 'always' }
79+
test2: { type: 'string', required: 'always' },
80+
test3: { type: 'number', required: true }
8081
},
8182
timestamps: false,
8283
table: TestTable3
@@ -497,6 +498,15 @@ describe('update',()=>{
497498
expect(TableName).toBe('test-table')
498499
})
499500

501+
it('accepts 0 as a valid value for required fields', () => {
502+
let { ExpressionAttributeValues } = TestEntity3.updateParams({
503+
pk: 'test-pk',
504+
test2: 'test',
505+
test3: 0
506+
})
507+
expect(ExpressionAttributeValues![':test3']).toBe(0)
508+
})
509+
500510
it('fails with undefined input', () => {
501511
expect(() => TestEntity.updateParams()).toThrow(`'pk' or 'email' is required`)
502512
})

0 commit comments

Comments
 (0)