@tomei/sso 0.8.9 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc +16 -16
  3. package/.eslintrc.js +35 -35
  4. package/.husky/commit-msg +15 -15
  5. package/.husky/pre-commit +7 -7
  6. package/.prettierrc +4 -5
  7. package/Jenkinsfile +57 -57
  8. package/README.md +23 -23
  9. package/__tests__/unit/components/login-history/login-history.repository.spec.ts +95 -95
  10. package/__tests__/unit/components/login-user/login-user.spec.ts +731 -731
  11. package/__tests__/unit/components/login-user/user.repository.spec.ts +81 -81
  12. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
  13. package/__tests__/unit/components/system/system.repository.spec.ts +88 -88
  14. package/__tests__/unit/components/system-access/system-access.repository.spec.ts +78 -78
  15. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  16. package/__tests__/unit/session/session.service.spec.ts +47 -47
  17. package/create-sso-user.sql +39 -39
  18. package/dist/__tests__/unit/redis-client/redis.service.spec.d.ts +1 -1
  19. package/dist/__tests__/unit/redis-client/redis.service.spec.js +31 -31
  20. package/dist/__tests__/unit/session/session.service.spec.d.ts +1 -1
  21. package/dist/__tests__/unit/session/session.service.spec.js +54 -54
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +17 -17
  24. package/dist/src/components/index.d.ts +7 -7
  25. package/dist/src/components/index.js +23 -23
  26. package/dist/src/components/login-history/index.d.ts +1 -1
  27. package/dist/src/components/login-history/index.js +17 -17
  28. package/dist/src/components/login-history/login-history.repository.d.ts +5 -5
  29. package/dist/src/components/login-history/login-history.repository.js +11 -11
  30. package/dist/src/components/login-user/index.d.ts +3 -3
  31. package/dist/src/components/login-user/index.js +19 -19
  32. package/dist/src/components/login-user/interfaces/index.d.ts +1 -1
  33. package/dist/src/components/login-user/interfaces/index.js +17 -17
  34. package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +9 -9
  35. package/dist/src/components/login-user/interfaces/user-info.interface.js +2 -2
  36. package/dist/src/components/login-user/login-user.d.ts +44 -44
  37. package/dist/src/components/login-user/login-user.js +416 -414
  38. package/dist/src/components/login-user/login-user.js.map +1 -1
  39. package/dist/src/components/login-user/user.repository.d.ts +5 -5
  40. package/dist/src/components/login-user/user.repository.js +11 -11
  41. package/dist/src/components/password-hash/index.d.ts +2 -2
  42. package/dist/src/components/password-hash/index.js +18 -18
  43. package/dist/src/components/password-hash/interfaces/index.d.ts +1 -1
  44. package/dist/src/components/password-hash/interfaces/index.js +17 -17
  45. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.d.ts +4 -4
  46. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js +2 -2
  47. package/dist/src/components/password-hash/password-hash.service.d.ts +6 -6
  48. package/dist/src/components/password-hash/password-hash.service.js +27 -27
  49. package/dist/src/components/system/index.d.ts +1 -1
  50. package/dist/src/components/system/index.js +17 -17
  51. package/dist/src/components/system/system.repository.d.ts +5 -5
  52. package/dist/src/components/system/system.repository.js +11 -11
  53. package/dist/src/components/system-access/index.d.ts +1 -1
  54. package/dist/src/components/system-access/index.js +17 -17
  55. package/dist/src/components/system-access/system-access.repository.d.ts +5 -5
  56. package/dist/src/components/system-access/system-access.repository.js +11 -11
  57. package/dist/src/components/user-group/index.d.ts +1 -1
  58. package/dist/src/components/user-group/index.js +17 -17
  59. package/dist/src/components/user-group/user-group.repository.d.ts +5 -5
  60. package/dist/src/components/user-group/user-group.repository.js +11 -11
  61. package/dist/src/components/user-user-group/index.d.ts +1 -1
  62. package/dist/src/components/user-user-group/index.js +17 -17
  63. package/dist/src/components/user-user-group/user-user-group.repository.d.ts +5 -5
  64. package/dist/src/components/user-user-group/user-user-group.repository.js +11 -11
  65. package/dist/src/database.d.ts +4 -4
  66. package/dist/src/database.js +14 -14
  67. package/dist/src/index.d.ts +5 -5
  68. package/dist/src/index.js +23 -22
  69. package/dist/src/index.js.map +1 -1
  70. package/dist/src/interfaces/index.d.ts +2 -2
  71. package/dist/src/interfaces/index.js +18 -18
  72. package/dist/src/interfaces/system-login.interface.d.ts +6 -6
  73. package/dist/src/interfaces/system-login.interface.js +2 -2
  74. package/dist/src/interfaces/user-session.interface.d.ts +4 -4
  75. package/dist/src/interfaces/user-session.interface.js +2 -2
  76. package/dist/src/models/authorization-code.entity.d.ts +14 -14
  77. package/dist/src/models/authorization-code.entity.js +85 -85
  78. package/dist/src/models/bearer-token.entity.d.ts +11 -11
  79. package/dist/src/models/bearer-token.entity.js +71 -71
  80. package/dist/src/models/building-type.entity.d.ts +7 -7
  81. package/dist/src/models/building-type.entity.js +49 -49
  82. package/dist/src/models/building.entity.d.ts +39 -39
  83. package/dist/src/models/building.entity.js +250 -250
  84. package/dist/src/models/city.entity.d.ts +11 -11
  85. package/dist/src/models/city.entity.js +71 -71
  86. package/dist/src/models/company.entity.d.ts +18 -18
  87. package/dist/src/models/company.entity.js +113 -113
  88. package/dist/src/models/country.entity.d.ts +15 -15
  89. package/dist/src/models/country.entity.js +91 -91
  90. package/dist/src/models/department.entity.d.ts +19 -19
  91. package/dist/src/models/department.entity.js +111 -111
  92. package/dist/src/models/group-role-privilege.entity.d.ts +17 -17
  93. package/dist/src/models/group-role-privilege.entity.js +89 -89
  94. package/dist/src/models/group-system-access.entity.d.ts +11 -11
  95. package/dist/src/models/group-system-access.entity.js +61 -61
  96. package/dist/src/models/group-system-privilege.entity.d.ts +11 -11
  97. package/dist/src/models/group-system-privilege.entity.js +61 -61
  98. package/dist/src/models/group-system-role.entity.d.ts +11 -11
  99. package/dist/src/models/group-system-role.entity.js +61 -61
  100. package/dist/src/models/login-history.entity.d.ts +12 -12
  101. package/dist/src/models/login-history.entity.js +69 -69
  102. package/dist/src/models/oauth-token.entity.d.ts +14 -14
  103. package/dist/src/models/oauth-token.entity.js +85 -85
  104. package/dist/src/models/role.entity.d.ts +17 -17
  105. package/dist/src/models/role.entity.js +101 -101
  106. package/dist/src/models/staff-type.entity.d.ts +7 -7
  107. package/dist/src/models/staff-type.entity.js +49 -49
  108. package/dist/src/models/staff.entity.d.ts +39 -39
  109. package/dist/src/models/staff.entity.js +249 -249
  110. package/dist/src/models/state.entity.d.ts +10 -10
  111. package/dist/src/models/state.entity.js +63 -63
  112. package/dist/src/models/system-accesss.entity.d.ts +6 -6
  113. package/dist/src/models/system-accesss.entity.js +50 -50
  114. package/dist/src/models/system-privilege.entity.d.ts +16 -16
  115. package/dist/src/models/system-privilege.entity.js +89 -89
  116. package/dist/src/models/system-role-privilege.entity.d.ts +11 -11
  117. package/dist/src/models/system-role-privilege.entity.js +59 -59
  118. package/dist/src/models/system-role.entity.d.ts +11 -11
  119. package/dist/src/models/system-role.entity.js +82 -82
  120. package/dist/src/models/system.entity.d.ts +19 -19
  121. package/dist/src/models/system.entity.js +145 -145
  122. package/dist/src/models/user-group.entity.d.ts +23 -23
  123. package/dist/src/models/user-group.entity.js +139 -139
  124. package/dist/src/models/user-role.entity.d.ts +12 -12
  125. package/dist/src/models/user-role.entity.js +72 -72
  126. package/dist/src/models/user-system-privileges.entity.d.ts +13 -13
  127. package/dist/src/models/user-system-privileges.entity.js +88 -88
  128. package/dist/src/models/user-system-role.entity.d.ts +11 -11
  129. package/dist/src/models/user-system-role.entity.js +59 -59
  130. package/dist/src/models/user-user-group.entity.d.ts +14 -14
  131. package/dist/src/models/user-user-group.entity.js +72 -72
  132. package/dist/src/models/user.entity.d.ts +30 -30
  133. package/dist/src/models/user.entity.js +130 -130
  134. package/dist/src/prisma-client/__mocks__/prisma.d.ts +3 -3
  135. package/dist/src/prisma-client/__mocks__/prisma.js +13 -13
  136. package/dist/src/prisma-client/client.d.ts +3 -3
  137. package/dist/src/prisma-client/client.js +5 -5
  138. package/dist/src/prisma-client/index.d.ts +1 -1
  139. package/dist/src/prisma-client/index.js +17 -17
  140. package/dist/src/redis-client/__mocks__/jest-initial-setup.d.ts +1 -1
  141. package/dist/src/redis-client/__mocks__/jest-initial-setup.js +4 -4
  142. package/dist/src/redis-client/__mocks__/redis-mock.d.ts +2 -2
  143. package/dist/src/redis-client/__mocks__/redis-mock.js +22 -22
  144. package/dist/src/redis-client/index.d.ts +1 -1
  145. package/dist/src/redis-client/index.js +17 -17
  146. package/dist/src/redis-client/redis.service.d.ts +7 -7
  147. package/dist/src/redis-client/redis.service.js +55 -55
  148. package/dist/src/session/index.d.ts +2 -2
  149. package/dist/src/session/index.js +18 -18
  150. package/dist/src/session/interfaces/index.d.ts +1 -1
  151. package/dist/src/session/interfaces/index.js +17 -17
  152. package/dist/src/session/interfaces/session-service.interface.d.ts +6 -6
  153. package/dist/src/session/interfaces/session-service.interface.js +2 -2
  154. package/dist/src/session/session.service.d.ts +10 -10
  155. package/dist/src/session/session.service.js +63 -63
  156. package/dist/tsconfig.tsbuildinfo +1 -1
  157. package/jest.config.js +14 -14
  158. package/migrations/01-alter-system-privilege-table.js +13 -13
  159. package/migrations/02-alter-user-group-table.js +78 -78
  160. package/migrations/03-alter-user-system-privilege-table.js +38 -38
  161. package/migrations/04-create-user-user-group-table.js +55 -55
  162. package/migrations/05-create-login-history-table.js +49 -49
  163. package/package.json +77 -81
  164. package/sampledotenv +7 -7
  165. package/src/components/login-user/login-user.ts +4 -6
  166. package/src/index.ts +1 -1
  167. package/tsconfig.build.json +5 -5
  168. package/tsconfig.json +23 -23
  169. package/prisma/migrations/0_init/migration.sql +0 -512
  170. package/prisma/migrations/20230528161352_create_user_user_group_and_add_new_column/migration.sql +0 -35
  171. package/prisma/migrations/20230606091407_create_login_histories_table/migration.sql +0 -17
  172. package/prisma/migrations/migration_lock.toml +0 -3
  173. package/prisma/schema.prisma +0 -519
  174. package/src/prisma-client/__mocks__/prisma.ts +0 -15
  175. package/src/prisma-client/client.ts +0 -3
  176. package/src/prisma-client/index.ts +0 -1
@@ -1,81 +1,81 @@
1
- // import { UserRepository } from '../../../../src/components/login-user/user.repository';
2
- // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
-
4
- // describe('system-access.repository', () => {
5
- // const data = {
6
- // id: 1,
7
- // email: 'test@test.email.com',
8
- // password: '@H34f5yRE',
9
- // status: 'Active',
10
- // defaultPasswordChanged: false,
11
- // firstLoginAt: new Date(),
12
- // createdAt: new Date(),
13
- // updatedAt: new Date(),
14
- // groupCode: 'RDAS',
15
- // };
16
-
17
- // afterEach(() => {
18
- // jest.restoreAllMocks();
19
- // });
20
- // describe('findAll', () => {
21
- // it('should return list of user', async () => {
22
- // prismaMock.user.findMany.mockResolvedValueOnce([data]);
23
- // const userRepository = new UserRepository();
24
- // expect(await userRepository.findAll({})).toEqual([data]);
25
- // });
26
- // });
27
-
28
- // describe('findOne', () => {
29
- // it('should return user', async () => {
30
- // prismaMock.user.findFirst.mockResolvedValueOnce(data);
31
- // const userRepository = new UserRepository();
32
- // expect(
33
- // await userRepository.findOne({
34
- // where: {
35
- // id: data.id,
36
- // },
37
- // }),
38
- // ).toEqual(data);
39
- // });
40
- // });
41
-
42
- // describe('create', () => {
43
- // it('should create user', async () => {
44
- // prismaMock.user.create.mockResolvedValueOnce(data);
45
- // const userRepository = new UserRepository();
46
- // expect(await userRepository.create(data)).toEqual(data);
47
- // });
48
- // });
49
-
50
- // describe('update', () => {
51
- // it('should update user', async () => {
52
- // prismaMock.user.update.mockResolvedValueOnce(data);
53
- // const userRepository = new UserRepository();
54
- // expect(
55
- // await userRepository.update(
56
- // {
57
- // where: {
58
- // id: data.id,
59
- // },
60
- // data: data,
61
- // },
62
- // data,
63
- // ),
64
- // ).toEqual(data);
65
- // });
66
- // });
67
-
68
- // describe('delete', () => {
69
- // it('should delete user', async () => {
70
- // prismaMock.user.delete.mockResolvedValueOnce(data);
71
- // const userRepository = new UserRepository();
72
- // expect(
73
- // await userRepository.delete({
74
- // where: {
75
- // id: data.id,
76
- // },
77
- // }),
78
- // ).toEqual(data);
79
- // });
80
- // });
81
- // });
1
+ // import { UserRepository } from '../../../../src/components/login-user/user.repository';
2
+ // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
+
4
+ // describe('system-access.repository', () => {
5
+ // const data = {
6
+ // id: 1,
7
+ // email: 'test@test.email.com',
8
+ // password: '@H34f5yRE',
9
+ // status: 'Active',
10
+ // defaultPasswordChanged: false,
11
+ // firstLoginAt: new Date(),
12
+ // createdAt: new Date(),
13
+ // updatedAt: new Date(),
14
+ // groupCode: 'RDAS',
15
+ // };
16
+
17
+ // afterEach(() => {
18
+ // jest.restoreAllMocks();
19
+ // });
20
+ // describe('findAll', () => {
21
+ // it('should return list of user', async () => {
22
+ // prismaMock.user.findMany.mockResolvedValueOnce([data]);
23
+ // const userRepository = new UserRepository();
24
+ // expect(await userRepository.findAll({})).toEqual([data]);
25
+ // });
26
+ // });
27
+
28
+ // describe('findOne', () => {
29
+ // it('should return user', async () => {
30
+ // prismaMock.user.findFirst.mockResolvedValueOnce(data);
31
+ // const userRepository = new UserRepository();
32
+ // expect(
33
+ // await userRepository.findOne({
34
+ // where: {
35
+ // id: data.id,
36
+ // },
37
+ // }),
38
+ // ).toEqual(data);
39
+ // });
40
+ // });
41
+
42
+ // describe('create', () => {
43
+ // it('should create user', async () => {
44
+ // prismaMock.user.create.mockResolvedValueOnce(data);
45
+ // const userRepository = new UserRepository();
46
+ // expect(await userRepository.create(data)).toEqual(data);
47
+ // });
48
+ // });
49
+
50
+ // describe('update', () => {
51
+ // it('should update user', async () => {
52
+ // prismaMock.user.update.mockResolvedValueOnce(data);
53
+ // const userRepository = new UserRepository();
54
+ // expect(
55
+ // await userRepository.update(
56
+ // {
57
+ // where: {
58
+ // id: data.id,
59
+ // },
60
+ // data: data,
61
+ // },
62
+ // data,
63
+ // ),
64
+ // ).toEqual(data);
65
+ // });
66
+ // });
67
+
68
+ // describe('delete', () => {
69
+ // it('should delete user', async () => {
70
+ // prismaMock.user.delete.mockResolvedValueOnce(data);
71
+ // const userRepository = new UserRepository();
72
+ // expect(
73
+ // await userRepository.delete({
74
+ // where: {
75
+ // id: data.id,
76
+ // },
77
+ // }),
78
+ // ).toEqual(data);
79
+ // });
80
+ // });
81
+ // });
@@ -1,32 +1,32 @@
1
- // import { PasswordHashService } from "../../../../src/components/password-hash/password-hash.service";
2
-
3
- // jest.mock('argon2', () => {
4
- // return {
5
- // hash: jest.fn((passowrd) => {
6
- // return `hash${passowrd}`;
7
- // }),
8
- // verify: jest.fn().mockResolvedValue(true)
9
- // }
10
- // })
11
-
12
- // describe('password-hash.service', () => {
13
- // const passwordHashService = new PasswordHashService();
14
- // afterEach(() => {
15
- // jest.clearAllMocks();
16
- // });
17
-
18
- // it('should return hash password', async () => {
19
- // const password = 'password';
20
- // const hash = await passwordHashService.hashPassword(password);
21
- // expect(hash).toEqual('hashpassword');
22
- // })
23
-
24
- // it('should return true when verify password', async () => {
25
- // const password = 'password';
26
- // const hash = 'hashpassword10';
27
- // const result = await passwordHashService.verify(password, hash);
28
- // expect(result).toEqual(true);
29
- // });
30
-
31
-
1
+ // import { PasswordHashService } from "../../../../src/components/password-hash/password-hash.service";
2
+
3
+ // jest.mock('argon2', () => {
4
+ // return {
5
+ // hash: jest.fn((passowrd) => {
6
+ // return `hash${passowrd}`;
7
+ // }),
8
+ // verify: jest.fn().mockResolvedValue(true)
9
+ // }
10
+ // })
11
+
12
+ // describe('password-hash.service', () => {
13
+ // const passwordHashService = new PasswordHashService();
14
+ // afterEach(() => {
15
+ // jest.clearAllMocks();
16
+ // });
17
+
18
+ // it('should return hash password', async () => {
19
+ // const password = 'password';
20
+ // const hash = await passwordHashService.hashPassword(password);
21
+ // expect(hash).toEqual('hashpassword');
22
+ // })
23
+
24
+ // it('should return true when verify password', async () => {
25
+ // const password = 'password';
26
+ // const hash = 'hashpassword10';
27
+ // const result = await passwordHashService.verify(password, hash);
28
+ // expect(result).toEqual(true);
29
+ // });
30
+
31
+
32
32
  // })
@@ -1,88 +1,88 @@
1
- // import { SystemRepository } from '../../../../src/components/system/system.repository';
2
- // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
-
4
- // describe('system.repository', () => {
5
- // const data = {
6
- // id: 175,
7
- // code: 'EZC',
8
- // name: 'EzCash',
9
- // description: 'Tomei Money Lending System',
10
- // accessUrl: 'https://app.ezcash.com.my:22443/staff/login',
11
- // googlePlayUrl: '',
12
- // appleStoreUrl: '',
13
- // apiKey: 'f3fef257jt',
14
- // logo: 'https://sso-api.tomei.com.my/upload/2023/01/10/FJ3DoHdRZKjf2bGkgA4E-BrowserIcon.png',
15
- // status: 'active',
16
- // visible: true,
17
- // createdAt: new Date(),
18
- // updatedAt: new Date(),
19
- // apiSecret: '12345',
20
- // updatedById: 61,
21
- // createdById: 100,
22
- // };
23
-
24
- // afterEach(() => {
25
- // jest.restoreAllMocks();
26
- // });
27
- // describe('findAll', () => {
28
- // it('should return list of system', async () => {
29
- // prismaMock.system.findMany.mockResolvedValueOnce([data]);
30
- // const systemRepository = new SystemRepository();
31
- // expect(await systemRepository.findAll({})).toEqual([data]);
32
- // });
33
- // });
34
-
35
- // describe('findOne', () => {
36
- // it('should return system', async () => {
37
- // prismaMock.system.findFirst.mockResolvedValueOnce(data);
38
- // const systemRepository = new SystemRepository();
39
- // expect(
40
- // await systemRepository.findOne({
41
- // where: {
42
- // id: data.id,
43
- // },
44
- // }),
45
- // ).toEqual(data);
46
- // });
47
- // });
48
-
49
- // describe('create', () => {
50
- // it('should create system', async () => {
51
- // prismaMock.system.create.mockResolvedValueOnce(data);
52
- // const systemRepository = new SystemRepository();
53
- // expect(await systemRepository.create(data)).toEqual(data);
54
- // });
55
- // });
56
-
57
- // describe('update', () => {
58
- // it('should update system', async () => {
59
- // prismaMock.system.update.mockResolvedValueOnce(data);
60
- // const systemRepository = new SystemRepository();
61
- // expect(
62
- // await systemRepository.update(
63
- // {
64
- // where: {
65
- // id: data.id,
66
- // },
67
- // data: data,
68
- // },
69
- // data,
70
- // ),
71
- // ).toEqual(data);
72
- // });
73
- // });
74
-
75
- // describe('delete', () => {
76
- // it('should delete system', async () => {
77
- // prismaMock.system.delete.mockResolvedValueOnce(data);
78
- // const systemRepository = new SystemRepository();
79
- // expect(
80
- // await systemRepository.delete({
81
- // where: {
82
- // id: data.id,
83
- // },
84
- // }),
85
- // ).toEqual(data);
86
- // });
87
- // });
88
- // });
1
+ // import { SystemRepository } from '../../../../src/components/system/system.repository';
2
+ // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
+
4
+ // describe('system.repository', () => {
5
+ // const data = {
6
+ // id: 175,
7
+ // code: 'EZC',
8
+ // name: 'EzCash',
9
+ // description: 'Tomei Money Lending System',
10
+ // accessUrl: 'https://app.ezcash.com.my:22443/staff/login',
11
+ // googlePlayUrl: '',
12
+ // appleStoreUrl: '',
13
+ // apiKey: 'f3fef257jt',
14
+ // logo: 'https://sso-api.tomei.com.my/upload/2023/01/10/FJ3DoHdRZKjf2bGkgA4E-BrowserIcon.png',
15
+ // status: 'active',
16
+ // visible: true,
17
+ // createdAt: new Date(),
18
+ // updatedAt: new Date(),
19
+ // apiSecret: '12345',
20
+ // updatedById: 61,
21
+ // createdById: 100,
22
+ // };
23
+
24
+ // afterEach(() => {
25
+ // jest.restoreAllMocks();
26
+ // });
27
+ // describe('findAll', () => {
28
+ // it('should return list of system', async () => {
29
+ // prismaMock.system.findMany.mockResolvedValueOnce([data]);
30
+ // const systemRepository = new SystemRepository();
31
+ // expect(await systemRepository.findAll({})).toEqual([data]);
32
+ // });
33
+ // });
34
+
35
+ // describe('findOne', () => {
36
+ // it('should return system', async () => {
37
+ // prismaMock.system.findFirst.mockResolvedValueOnce(data);
38
+ // const systemRepository = new SystemRepository();
39
+ // expect(
40
+ // await systemRepository.findOne({
41
+ // where: {
42
+ // id: data.id,
43
+ // },
44
+ // }),
45
+ // ).toEqual(data);
46
+ // });
47
+ // });
48
+
49
+ // describe('create', () => {
50
+ // it('should create system', async () => {
51
+ // prismaMock.system.create.mockResolvedValueOnce(data);
52
+ // const systemRepository = new SystemRepository();
53
+ // expect(await systemRepository.create(data)).toEqual(data);
54
+ // });
55
+ // });
56
+
57
+ // describe('update', () => {
58
+ // it('should update system', async () => {
59
+ // prismaMock.system.update.mockResolvedValueOnce(data);
60
+ // const systemRepository = new SystemRepository();
61
+ // expect(
62
+ // await systemRepository.update(
63
+ // {
64
+ // where: {
65
+ // id: data.id,
66
+ // },
67
+ // data: data,
68
+ // },
69
+ // data,
70
+ // ),
71
+ // ).toEqual(data);
72
+ // });
73
+ // });
74
+
75
+ // describe('delete', () => {
76
+ // it('should delete system', async () => {
77
+ // prismaMock.system.delete.mockResolvedValueOnce(data);
78
+ // const systemRepository = new SystemRepository();
79
+ // expect(
80
+ // await systemRepository.delete({
81
+ // where: {
82
+ // id: data.id,
83
+ // },
84
+ // }),
85
+ // ).toEqual(data);
86
+ // });
87
+ // });
88
+ // });
@@ -1,78 +1,78 @@
1
- // import { SystemAccessRepository } from '../../../../src/components/system-access/system-access.repository';
2
- // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
-
4
- // describe('system-access.repository', () => {
5
- // const data = {
6
- // userId: 1,
7
- // systemId: 175,
8
- // updatedAt: new Date(),
9
- // };
10
-
11
- // afterEach(() => {
12
- // jest.restoreAllMocks();
13
- // });
14
- // describe('findAll', () => {
15
- // it('should return list of system access', async () => {
16
- // prismaMock.systemAccess.findMany.mockResolvedValueOnce([data]);
17
- // const systemAccessRepository = new SystemAccessRepository();
18
- // expect(await systemAccessRepository.findAll({})).toEqual([data]);
19
- // });
20
- // });
21
-
22
- // describe('findOne', () => {
23
- // it('should return system access', async () => {
24
- // prismaMock.systemAccess.findFirst.mockResolvedValueOnce(data);
25
- // const systemAccessRepository = new SystemAccessRepository();
26
- // expect(
27
- // await systemAccessRepository.findOne({
28
- // where: {
29
- // userId: data.userId,
30
- // systemId: data.systemId,
31
- // },
32
- // }),
33
- // ).toEqual(data);
34
- // });
35
- // });
36
-
37
- // describe('create', () => {
38
- // it('should create system access', async () => {
39
- // prismaMock.systemAccess.create.mockResolvedValueOnce(data);
40
- // const systemAccessRepository = new SystemAccessRepository();
41
- // expect(await systemAccessRepository.create(data)).toEqual(data);
42
- // });
43
- // });
44
-
45
- // describe('update', () => {
46
- // it('should update system access', async () => {
47
- // prismaMock.systemAccess.update.mockResolvedValueOnce(data);
48
- // const systemAccessRepository = new SystemAccessRepository();
49
- // expect(
50
- // await systemAccessRepository.update(
51
- // {
52
- // where: {
53
- // userId: data.userId,
54
- // systemId: data.systemId,
55
- // },
56
- // data: data,
57
- // },
58
- // data,
59
- // ),
60
- // ).toEqual(data);
61
- // });
62
- // });
63
-
64
- // describe('delete', () => {
65
- // it('should delete system access', async () => {
66
- // prismaMock.systemAccess.delete.mockResolvedValueOnce(data);
67
- // const systemAccessRepository = new SystemAccessRepository();
68
- // expect(
69
- // await systemAccessRepository.delete({
70
- // where: {
71
- // userId: data.userId,
72
- // systemId: data.systemId,
73
- // },
74
- // }),
75
- // ).toEqual(data);
76
- // });
77
- // });
78
- // });
1
+ // import { SystemAccessRepository } from '../../../../src/components/system-access/system-access.repository';
2
+ // import { prismaMock } from '../../../../src/prisma-client/__mocks__/prisma';
3
+
4
+ // describe('system-access.repository', () => {
5
+ // const data = {
6
+ // userId: 1,
7
+ // systemId: 175,
8
+ // updatedAt: new Date(),
9
+ // };
10
+
11
+ // afterEach(() => {
12
+ // jest.restoreAllMocks();
13
+ // });
14
+ // describe('findAll', () => {
15
+ // it('should return list of system access', async () => {
16
+ // prismaMock.systemAccess.findMany.mockResolvedValueOnce([data]);
17
+ // const systemAccessRepository = new SystemAccessRepository();
18
+ // expect(await systemAccessRepository.findAll({})).toEqual([data]);
19
+ // });
20
+ // });
21
+
22
+ // describe('findOne', () => {
23
+ // it('should return system access', async () => {
24
+ // prismaMock.systemAccess.findFirst.mockResolvedValueOnce(data);
25
+ // const systemAccessRepository = new SystemAccessRepository();
26
+ // expect(
27
+ // await systemAccessRepository.findOne({
28
+ // where: {
29
+ // userId: data.userId,
30
+ // systemId: data.systemId,
31
+ // },
32
+ // }),
33
+ // ).toEqual(data);
34
+ // });
35
+ // });
36
+
37
+ // describe('create', () => {
38
+ // it('should create system access', async () => {
39
+ // prismaMock.systemAccess.create.mockResolvedValueOnce(data);
40
+ // const systemAccessRepository = new SystemAccessRepository();
41
+ // expect(await systemAccessRepository.create(data)).toEqual(data);
42
+ // });
43
+ // });
44
+
45
+ // describe('update', () => {
46
+ // it('should update system access', async () => {
47
+ // prismaMock.systemAccess.update.mockResolvedValueOnce(data);
48
+ // const systemAccessRepository = new SystemAccessRepository();
49
+ // expect(
50
+ // await systemAccessRepository.update(
51
+ // {
52
+ // where: {
53
+ // userId: data.userId,
54
+ // systemId: data.systemId,
55
+ // },
56
+ // data: data,
57
+ // },
58
+ // data,
59
+ // ),
60
+ // ).toEqual(data);
61
+ // });
62
+ // });
63
+
64
+ // describe('delete', () => {
65
+ // it('should delete system access', async () => {
66
+ // prismaMock.systemAccess.delete.mockResolvedValueOnce(data);
67
+ // const systemAccessRepository = new SystemAccessRepository();
68
+ // expect(
69
+ // await systemAccessRepository.delete({
70
+ // where: {
71
+ // userId: data.userId,
72
+ // systemId: data.systemId,
73
+ // },
74
+ // }),
75
+ // ).toEqual(data);
76
+ // });
77
+ // });
78
+ // });
@@ -1,24 +1,24 @@
1
- import { RedisService } from "../../../src/redis-client/redis.service";
2
- require('dotenv').config()
3
- // nneed to figure out how to mock redis
4
- describe('redis.service', () => {
5
-
6
- afterEach(() => {
7
- jest.restoreAllMocks()
8
- })
9
-
10
- it('should return redis service when instansiated', async () => {
11
- const redisService = await RedisService.init();
12
- expect(redisService).toBeDefined();
13
- });
14
-
15
- it('should able to write and read redis', async () => {
16
- const data = {
17
- test: 'test'
18
- }
19
- const redisService = await RedisService.init();
20
- await redisService.set("test", data, 60 * 60 * 24 * 1)
21
- const result = await redisService.get("test");
22
- expect(result).toEqual(JSON.stringify(data));
23
- });
1
+ import { RedisService } from "../../../src/redis-client/redis.service";
2
+ require('dotenv').config()
3
+ // nneed to figure out how to mock redis
4
+ describe('redis.service', () => {
5
+
6
+ afterEach(() => {
7
+ jest.restoreAllMocks()
8
+ })
9
+
10
+ it('should return redis service when instansiated', async () => {
11
+ const redisService = await RedisService.init();
12
+ expect(redisService).toBeDefined();
13
+ });
14
+
15
+ it('should able to write and read redis', async () => {
16
+ const data = {
17
+ test: 'test'
18
+ }
19
+ const redisService = await RedisService.init();
20
+ await redisService.set("test", data, 60 * 60 * 24 * 1)
21
+ const result = await redisService.get("test");
22
+ expect(result).toEqual(JSON.stringify(data));
23
+ });
24
24
  });