-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.test.ts
More file actions
55 lines (48 loc) · 1.52 KB
/
user.test.ts
File metadata and controls
55 lines (48 loc) · 1.52 KB
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
49
50
51
52
53
54
55
import "reflect-metadata";
import {UserAdapter} from '@api/adapters/user.adapter';
import type {MasterAccount} from '@prisma/generated';
import type {UserModelDto} from '@shared/dto/models/user.model.dto';
describe('UserAdapter', () => {
let adapter: UserAdapter;
beforeEach(() => {
adapter = new UserAdapter();
});
describe('getUsersFromMasterAccounts()', () => {
it('should map an array of MasterAccount to UserModelDto[]', () => {
const masterAccounts: MasterAccount[] = [
{
id: '1',
email: 'alice@example.com',
password: 'secret1',
createdAt: new Date('2025-01-01T00:00:00.000Z'),
} as any,
{
id: '2',
email: 'bob@example.com',
password: 'secret2',
createdAt: new Date('2025-02-02T00:00:00.000Z'),
} as any,
];
const expected: UserModelDto[] = [
{
id: '1',
email: 'alice@example.com',
password: 'secret1',
createdAt: new Date('2025-01-01T00:00:00.000Z'),
},
{
id: '2',
email: 'bob@example.com',
password: 'secret2',
createdAt: new Date('2025-02-02T00:00:00.000Z'),
},
];
const result = adapter.getUsersFromMasterAccounts(masterAccounts);
expect(result).toEqual(expected);
});
it('should return an empty array when passed an empty array', () => {
const result = adapter.getUsersFromMasterAccounts([]);
expect(result).toEqual([]);
});
});
});