-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.test.ts
48 lines (41 loc) · 1.12 KB
/
converter.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Converter } from './converter';
describe('converter.ts', () => {
test('input', () => {
const pictureBuffer = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
'base64',
);
const user = {
id: 575,
name: 'Danny',
favorites: ['apples', 'pears'],
lastPayment: null,
createdAt: new Date('2021-07-09T21:44:07.015Z'),
address: {
streetNumber: 112,
streetName: 'Drive',
},
profilePicture: pictureBuffer,
};
const userObject = Converter.marshall(user);
expect(userObject).toEqual({
id: { N: '575' },
name: { S: 'Danny' },
favorites: { L: [{ S: 'apples' }, { S: 'pears' }] },
lastPayment: { NULL: true },
createdAt: { S: '2021-07-09T21:44:07.015Z' },
address: {
M: { streetNumber: { N: '112' }, streetName: { S: 'Drive' } },
},
profilePicture: {
B: pictureBuffer,
},
});
const unmarshalled = Converter.unmarshall(userObject);
const stringDateUser = {
...user,
createdAt: '2021-07-09T21:44:07.015Z',
};
expect(unmarshalled).toEqual(stringDateUser);
});
});