@hedhog/admin 0.0.39 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/auth/auth.service.spec.d.ts +2 -0
  2. package/dist/auth/auth.service.spec.d.ts.map +1 -0
  3. package/dist/auth/auth.service.spec.js +163 -0
  4. package/dist/auth/auth.service.spec.js.map +1 -0
  5. package/dist/locale/locale.module.js +2 -2
  6. package/dist/locale/locale.module.js.map +1 -1
  7. package/dist/locale/locale.service.js +1 -1
  8. package/dist/locale/locale.service.js.map +1 -1
  9. package/dist/locale/locale.service.spec.d.ts +2 -0
  10. package/dist/locale/locale.service.spec.d.ts.map +1 -0
  11. package/dist/locale/locale.service.spec.js +171 -0
  12. package/dist/locale/locale.service.spec.js.map +1 -0
  13. package/dist/menu/menu.service.spec.d.ts +2 -0
  14. package/dist/menu/menu.service.spec.d.ts.map +1 -0
  15. package/dist/menu/menu.service.spec.js +196 -0
  16. package/dist/menu/menu.service.spec.js.map +1 -0
  17. package/dist/role/role.service.spec.d.ts +2 -0
  18. package/dist/role/role.service.spec.d.ts.map +1 -0
  19. package/dist/role/role.service.spec.js +343 -0
  20. package/dist/role/role.service.spec.js.map +1 -0
  21. package/dist/route/route.service.spec.d.ts +2 -0
  22. package/dist/route/route.service.spec.d.ts.map +1 -0
  23. package/dist/route/route.service.spec.js +235 -0
  24. package/dist/route/route.service.spec.js.map +1 -0
  25. package/dist/screen/screen.service.spec.d.ts +2 -0
  26. package/dist/screen/screen.service.spec.d.ts.map +1 -0
  27. package/dist/screen/screen.service.spec.js +242 -0
  28. package/dist/screen/screen.service.spec.js.map +1 -0
  29. package/dist/setting/settings.service.spec.d.ts +2 -0
  30. package/dist/setting/settings.service.spec.d.ts.map +1 -0
  31. package/dist/setting/settings.service.spec.js +147 -0
  32. package/dist/setting/settings.service.spec.js.map +1 -0
  33. package/dist/user/user.service.spec.d.ts +2 -0
  34. package/dist/user/user.service.spec.d.ts.map +1 -0
  35. package/dist/user/user.service.spec.js +239 -0
  36. package/dist/user/user.service.spec.js.map +1 -0
  37. package/package.json +1 -1
  38. package/src/migrations/migrate-02.ts +137 -137
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.service.spec.d.ts","sourceRoot":"","sources":["../../src/role/role.service.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const role_service_1 = require("./role.service");
5
+ const prisma_1 = require("@hedhog/prisma");
6
+ const pagination_1 = require("@hedhog/pagination");
7
+ const common_1 = require("@nestjs/common");
8
+ describe('RoleService', () => {
9
+ let roleService;
10
+ let prismaService;
11
+ let paginationService;
12
+ beforeEach(async () => {
13
+ const module = await testing_1.Test.createTestingModule({
14
+ providers: [
15
+ role_service_1.RoleService,
16
+ {
17
+ provide: prisma_1.PrismaService,
18
+ useValue: {
19
+ roles: {
20
+ create: jest.fn(),
21
+ update: jest.fn(),
22
+ findUnique: jest.fn(),
23
+ deleteMany: jest.fn(),
24
+ findMany: jest.fn(),
25
+ },
26
+ role_users: {
27
+ deleteMany: jest.fn(),
28
+ createMany: jest.fn(),
29
+ },
30
+ role_menus: {
31
+ deleteMany: jest.fn(),
32
+ createMany: jest.fn(),
33
+ },
34
+ role_screens: {
35
+ deleteMany: jest.fn(),
36
+ createMany: jest.fn(),
37
+ },
38
+ role_routes: {
39
+ deleteMany: jest.fn(),
40
+ createMany: jest.fn(),
41
+ },
42
+ },
43
+ },
44
+ {
45
+ provide: pagination_1.PaginationService,
46
+ useValue: {
47
+ paginate: jest.fn(),
48
+ },
49
+ },
50
+ ],
51
+ }).compile();
52
+ roleService = module.get(role_service_1.RoleService);
53
+ prismaService = module.get(prisma_1.PrismaService);
54
+ paginationService = module.get(pagination_1.PaginationService);
55
+ });
56
+ describe('create', () => {
57
+ it('should create a new role', async () => {
58
+ const dto = {
59
+ name: 'Admin',
60
+ description: 'Administrator role',
61
+ };
62
+ const result = Object.assign(Object.assign({ id: 1 }, dto), { created_at: new Date(), updated_at: new Date() });
63
+ jest.spyOn(prismaService.roles, 'create').mockResolvedValue(result);
64
+ expect(await roleService.create(dto)).toEqual(result);
65
+ });
66
+ });
67
+ describe('update', () => {
68
+ it('should update an existing role', async () => {
69
+ const dto = {
70
+ name: 'Admin',
71
+ description: 'Updated description',
72
+ };
73
+ const result = Object.assign(Object.assign({ id: 1 }, dto), { created_at: new Date(), updated_at: new Date() });
74
+ jest.spyOn(prismaService.roles, 'update').mockResolvedValue(result);
75
+ expect(await roleService.update({ id: 1, data: dto })).toEqual(result);
76
+ });
77
+ });
78
+ describe('delete', () => {
79
+ it('should delete roles', async () => {
80
+ const dto = { ids: [1, 2] };
81
+ jest
82
+ .spyOn(prismaService.roles, 'deleteMany')
83
+ .mockResolvedValue({ count: 2 });
84
+ await roleService.delete(dto);
85
+ expect(prismaService.roles.deleteMany).toHaveBeenCalledWith({
86
+ where: {
87
+ id: { in: dto.ids },
88
+ },
89
+ });
90
+ });
91
+ it('should throw BadRequestException if no ids are provided', async () => {
92
+ const dto = { ids: null };
93
+ await expect(roleService.delete(dto)).rejects.toThrow(common_1.BadRequestException);
94
+ });
95
+ });
96
+ describe('updateUsers', () => {
97
+ it('should update users for a role', async () => {
98
+ const roleId = 1;
99
+ const data = { ids: [1, 2] };
100
+ jest
101
+ .spyOn(prismaService.role_users, 'deleteMany')
102
+ .mockResolvedValue({ count: 2 });
103
+ jest
104
+ .spyOn(prismaService.role_users, 'createMany')
105
+ .mockResolvedValue({ count: 2 });
106
+ await roleService.updateUsers(roleId, data);
107
+ expect(prismaService.role_users.deleteMany).toHaveBeenCalledWith({
108
+ where: { role_id: roleId },
109
+ });
110
+ expect(prismaService.role_users.createMany).toHaveBeenCalledWith({
111
+ data: data.ids.map((userId) => ({
112
+ role_id: roleId,
113
+ user_id: userId,
114
+ })),
115
+ skipDuplicates: true,
116
+ });
117
+ });
118
+ });
119
+ describe('updateScreens', () => {
120
+ it('should update screens for a role', async () => {
121
+ const roleId = 1;
122
+ const data = { ids: [1, 2] };
123
+ jest
124
+ .spyOn(prismaService.role_screens, 'deleteMany')
125
+ .mockResolvedValue({ count: 2 });
126
+ jest
127
+ .spyOn(prismaService.role_screens, 'createMany')
128
+ .mockResolvedValue({ count: 2 });
129
+ await roleService.updateScreens(roleId, data);
130
+ expect(prismaService.role_screens.deleteMany).toHaveBeenCalledWith({
131
+ where: { role_id: roleId },
132
+ });
133
+ expect(prismaService.role_screens.createMany).toHaveBeenCalledWith({
134
+ data: data.ids.map((screenId) => ({
135
+ role_id: roleId,
136
+ screen_id: screenId,
137
+ })),
138
+ skipDuplicates: true,
139
+ });
140
+ });
141
+ });
142
+ describe('updateRoutes', () => {
143
+ it('should update routes for a role', async () => {
144
+ const roleId = 1;
145
+ const data = { ids: [1, 2] };
146
+ jest
147
+ .spyOn(prismaService.role_routes, 'deleteMany')
148
+ .mockResolvedValue({ count: 2 });
149
+ jest
150
+ .spyOn(prismaService.role_routes, 'createMany')
151
+ .mockResolvedValue({ count: 2 });
152
+ await roleService.updateRoutes(roleId, data);
153
+ expect(prismaService.role_routes.deleteMany).toHaveBeenCalledWith({
154
+ where: { role_id: roleId },
155
+ });
156
+ expect(prismaService.role_routes.createMany).toHaveBeenCalledWith({
157
+ data: data.ids.map((routeId) => ({
158
+ role_id: roleId,
159
+ route_id: routeId,
160
+ })),
161
+ skipDuplicates: true,
162
+ });
163
+ });
164
+ });
165
+ describe('updateMenus', () => {
166
+ it('should update menus for a role', async () => {
167
+ const roleId = 1;
168
+ const data = { ids: [1, 2] };
169
+ jest
170
+ .spyOn(prismaService.role_menus, 'deleteMany')
171
+ .mockResolvedValue({ count: 2 });
172
+ jest
173
+ .spyOn(prismaService.role_menus, 'createMany')
174
+ .mockResolvedValue({ count: 2 });
175
+ await roleService.updateMenus(roleId, data);
176
+ expect(prismaService.role_menus.deleteMany).toHaveBeenCalledWith({
177
+ where: { role_id: roleId },
178
+ });
179
+ expect(prismaService.role_menus.createMany).toHaveBeenCalledWith({
180
+ data: data.ids.map((menuId) => ({
181
+ role_id: roleId,
182
+ menu_id: menuId,
183
+ })),
184
+ skipDuplicates: true,
185
+ });
186
+ });
187
+ });
188
+ describe('listUsers', () => {
189
+ it('should list users associated with a role', async () => {
190
+ const roleId = 1;
191
+ const paginationParams = {
192
+ page: 1,
193
+ pageSize: 10,
194
+ search: '',
195
+ sortField: '',
196
+ sortOrder: pagination_1.PageOrderDirection.Asc,
197
+ fields: '',
198
+ };
199
+ const mockPaginationResult = {
200
+ data: [],
201
+ total: 10,
202
+ lastPage: 1,
203
+ page: 1,
204
+ prev: 0,
205
+ next: 2,
206
+ pageSize: 10,
207
+ };
208
+ jest
209
+ .spyOn(paginationService, 'paginate')
210
+ .mockResolvedValue(mockPaginationResult);
211
+ await roleService.listUsers(roleId, paginationParams);
212
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.users, paginationParams, {
213
+ include: {
214
+ role_users: {
215
+ where: { role_id: roleId },
216
+ select: { user_id: true, role_id: true },
217
+ },
218
+ },
219
+ });
220
+ });
221
+ });
222
+ describe('listMenus', () => {
223
+ it('should list menus associated with a role', async () => {
224
+ const locale = 'en';
225
+ const roleId = 1;
226
+ const paginationParams = {
227
+ page: 1,
228
+ pageSize: 10,
229
+ search: '',
230
+ sortField: '',
231
+ sortOrder: pagination_1.PageOrderDirection.Asc,
232
+ fields: '',
233
+ };
234
+ const mockPaginationResult = {
235
+ data: [],
236
+ total: 10,
237
+ lastPage: 1,
238
+ page: 1,
239
+ prev: 0,
240
+ next: 2,
241
+ pageSize: 10,
242
+ };
243
+ jest
244
+ .spyOn(paginationService, 'paginate')
245
+ .mockResolvedValue(mockPaginationResult);
246
+ await roleService.listMenus(locale, roleId, paginationParams);
247
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.menus, paginationParams, {
248
+ include: {
249
+ menu_translations: {
250
+ where: { locales: { code: locale } },
251
+ select: { name: true },
252
+ },
253
+ role_menus: {
254
+ where: { role_id: roleId },
255
+ select: { menu_id: true, role_id: true },
256
+ },
257
+ },
258
+ }, 'menu_translations');
259
+ });
260
+ });
261
+ describe('listRoutes', () => {
262
+ it('should list routes associated with a role', async () => {
263
+ const roleId = 1;
264
+ const paginationParams = {
265
+ page: 1,
266
+ pageSize: 10,
267
+ search: '',
268
+ sortField: '',
269
+ sortOrder: pagination_1.PageOrderDirection.Asc,
270
+ fields: '',
271
+ };
272
+ const mockPaginationResult = {
273
+ data: [],
274
+ total: 10,
275
+ lastPage: 1,
276
+ page: 1,
277
+ prev: 0,
278
+ next: 2,
279
+ pageSize: 10,
280
+ };
281
+ jest
282
+ .spyOn(paginationService, 'paginate')
283
+ .mockResolvedValue(mockPaginationResult);
284
+ await roleService.listRoutes(roleId, paginationParams);
285
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.routes, paginationParams, {
286
+ include: {
287
+ role_routes: {
288
+ where: { role_id: roleId },
289
+ select: { route_id: true, role_id: true },
290
+ },
291
+ },
292
+ });
293
+ });
294
+ });
295
+ describe('listScreens', () => {
296
+ it('should list screens associated with a role', async () => {
297
+ const locale = 'en';
298
+ const roleId = 1;
299
+ const paginationParams = {
300
+ page: 1,
301
+ pageSize: 10,
302
+ search: '',
303
+ sortField: '',
304
+ sortOrder: pagination_1.PageOrderDirection.Asc,
305
+ fields: '',
306
+ };
307
+ const mockPaginationResult = {
308
+ data: [],
309
+ total: 10,
310
+ lastPage: 1,
311
+ page: 1,
312
+ prev: 0,
313
+ next: 2,
314
+ pageSize: 10,
315
+ };
316
+ jest
317
+ .spyOn(paginationService, 'paginate')
318
+ .mockResolvedValue(mockPaginationResult);
319
+ await roleService.listScreens(locale, roleId, paginationParams);
320
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.screens, paginationParams, {
321
+ include: {
322
+ screen_translations: {
323
+ where: { locales: { code: locale } },
324
+ select: { name: true },
325
+ },
326
+ role_screens: {
327
+ where: { role_id: roleId },
328
+ select: { screen_id: true, role_id: true },
329
+ },
330
+ },
331
+ }, 'screen_translations');
332
+ });
333
+ });
334
+ describe('get', () => {
335
+ it('should get a specific role by ID', async () => {
336
+ const roleId = 1;
337
+ const result = { id: roleId, name: 'Admin', description: 'Admin role' };
338
+ jest.spyOn(prismaService.roles, 'findUnique').mockResolvedValue(result);
339
+ expect(await roleService.get(roleId)).toEqual(result);
340
+ });
341
+ });
342
+ });
343
+ //# sourceMappingURL=role.service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.service.spec.js","sourceRoot":"","sources":["../../src/role/role.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,iDAA6C;AAC7C,2CAA+C;AAC/C,mDAI4B;AAC5B,2CAAqD;AAMrD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,WAAwB,CAAC;IAC7B,IAAI,aAA4B,CAAC;IACjC,IAAI,iBAAoC,CAAC;IAEzC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE;gBACT,0BAAW;gBACX;oBACE,OAAO,EAAE,sBAAa;oBACtB,QAAQ,EAAE;wBACR,KAAK,EAAE;4BACL,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;4BACjB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;4BACjB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;4BACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;4BACrB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;yBACpB;wBACD,UAAU,EAAE;4BACV,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;4BACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;yBACtB;wBACD,UAAU,EAAE;4BACV,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;4BACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;yBACtB;wBACD,YAAY,EAAE;4BACZ,UAAU,EAAE,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EAAE;wBACZ,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;wBAC1B,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;qBAC3C;iBACF;aACF,EACD,qBAAqB,CACtB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;QACnB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,MAAM,GAAG,CAAC,CAAC;YACjB,MAAM,MAAM,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;YAExE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAExE,MAAM,CAAC,MAAM,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=route.service.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.service.spec.d.ts","sourceRoot":"","sources":["../../src/route/route.service.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const pagination_1 = require("@hedhog/pagination");
5
+ const prisma_1 = require("@hedhog/prisma");
6
+ const route_service_1 = require("./route.service");
7
+ describe('RouteService', () => {
8
+ let service;
9
+ let prismaService;
10
+ let paginationService;
11
+ const mockPrismaService = {
12
+ routes: {
13
+ findUnique: jest.fn(),
14
+ create: jest.fn(),
15
+ update: jest.fn(),
16
+ deleteMany: jest.fn(),
17
+ },
18
+ role_routes: {
19
+ deleteMany: jest.fn(),
20
+ createMany: jest.fn(),
21
+ },
22
+ route_screens: {
23
+ deleteMany: jest.fn(),
24
+ createMany: jest.fn(),
25
+ },
26
+ createInsensitiveSearch: jest.fn(),
27
+ };
28
+ const mockPaginationService = {
29
+ paginate: jest.fn(),
30
+ };
31
+ beforeEach(async () => {
32
+ const module = await testing_1.Test.createTestingModule({
33
+ providers: [
34
+ route_service_1.RouteService,
35
+ { provide: prisma_1.PrismaService, useValue: mockPrismaService },
36
+ { provide: pagination_1.PaginationService, useValue: mockPaginationService },
37
+ ],
38
+ }).compile();
39
+ service = module.get(route_service_1.RouteService);
40
+ prismaService = module.get(prisma_1.PrismaService);
41
+ paginationService = module.get(pagination_1.PaginationService);
42
+ });
43
+ it('should be defined', () => {
44
+ expect(service).toBeDefined();
45
+ });
46
+ describe('getRoutes', () => {
47
+ it('should paginate routes', async () => {
48
+ const paginationParams = {
49
+ page: 1,
50
+ pageSize: 10,
51
+ search: '',
52
+ sortField: '',
53
+ sortOrder: pagination_1.PageOrderDirection.Asc,
54
+ fields: '',
55
+ };
56
+ const result = { data: [], total: 0 };
57
+ mockPrismaService.createInsensitiveSearch.mockReturnValue([]);
58
+ mockPaginationService.paginate.mockResolvedValue(result);
59
+ const res = await service.getRoutes(paginationParams);
60
+ expect(mockPrismaService.createInsensitiveSearch).toHaveBeenCalledWith(['url', 'method'], paginationParams);
61
+ expect(mockPaginationService.paginate).toHaveBeenCalledWith(mockPrismaService.routes, paginationParams, { where: { OR: [] } });
62
+ expect(res).toEqual(result);
63
+ });
64
+ });
65
+ describe('getRouteById', () => {
66
+ it('should return a route by ID', async () => {
67
+ const routeId = 1;
68
+ const route = { id: routeId, url: '/test', method: 'GET' };
69
+ mockPrismaService.routes.findUnique.mockResolvedValue(route);
70
+ const res = await service.getRouteById(routeId);
71
+ expect(mockPrismaService.routes.findUnique).toHaveBeenCalledWith({
72
+ where: { id: routeId },
73
+ });
74
+ expect(res).toEqual(route);
75
+ });
76
+ });
77
+ describe('create', () => {
78
+ it('should create a new route', async () => {
79
+ const createDto = { url: '/test', method: 'GET' };
80
+ const route = Object.assign({ id: 1 }, createDto);
81
+ mockPrismaService.routes.create.mockResolvedValue(route);
82
+ const res = await service.create(createDto);
83
+ expect(mockPrismaService.routes.create).toHaveBeenCalledWith({
84
+ data: createDto,
85
+ });
86
+ expect(res).toEqual(route);
87
+ });
88
+ });
89
+ describe('update', () => {
90
+ it('should update a route', async () => {
91
+ const updateDto = { url: '/updated', method: 'POST' };
92
+ const routeId = 1;
93
+ const updatedRoute = Object.assign({ id: routeId }, updateDto);
94
+ mockPrismaService.routes.update.mockResolvedValue(updatedRoute);
95
+ const res = await service.update({ id: routeId, data: updateDto });
96
+ expect(mockPrismaService.routes.update).toHaveBeenCalledWith({
97
+ where: { id: routeId },
98
+ data: updateDto,
99
+ });
100
+ expect(res).toEqual(updatedRoute);
101
+ });
102
+ });
103
+ describe('delete', () => {
104
+ it('should delete routes by ids', async () => {
105
+ const deleteDto = { ids: [1, 2] };
106
+ const result = { count: 2 };
107
+ mockPrismaService.routes.deleteMany.mockResolvedValue(result);
108
+ const res = await service.delete(deleteDto);
109
+ expect(mockPrismaService.routes.deleteMany).toHaveBeenCalledWith({
110
+ where: { id: { in: deleteDto.ids } },
111
+ });
112
+ expect(res).toEqual(result);
113
+ });
114
+ });
115
+ describe('updateRoles', () => {
116
+ it('should update roles for a route', async () => {
117
+ const routeId = 1;
118
+ const updateIdsDto = { ids: [1, 2] };
119
+ const result = { count: 2 };
120
+ mockPrismaService.role_routes.deleteMany.mockResolvedValue({});
121
+ mockPrismaService.role_routes.createMany.mockResolvedValue(result);
122
+ const res = await service.updateRoles(routeId, updateIdsDto);
123
+ expect(mockPrismaService.role_routes.deleteMany).toHaveBeenCalledWith({
124
+ where: { route_id: routeId },
125
+ });
126
+ expect(mockPrismaService.role_routes.createMany).toHaveBeenCalledWith({
127
+ data: updateIdsDto.ids.map((roleId) => ({
128
+ role_id: roleId,
129
+ route_id: routeId,
130
+ })),
131
+ skipDuplicates: true,
132
+ });
133
+ expect(res).toEqual(result);
134
+ });
135
+ });
136
+ describe('updateScreens', () => {
137
+ it('should update screens for a route', async () => {
138
+ const routeId = 1;
139
+ const updateIdsDto = { ids: [1, 2] };
140
+ const result = { count: 2 };
141
+ mockPrismaService.route_screens.deleteMany.mockResolvedValue({});
142
+ mockPrismaService.route_screens.createMany.mockResolvedValue(result);
143
+ const res = await service.updateScreens(routeId, updateIdsDto);
144
+ expect(mockPrismaService.route_screens.deleteMany).toHaveBeenCalledWith({
145
+ where: { route_id: routeId },
146
+ });
147
+ expect(mockPrismaService.route_screens.createMany).toHaveBeenCalledWith({
148
+ data: updateIdsDto.ids.map((screenId) => ({
149
+ screen_id: screenId,
150
+ route_id: routeId,
151
+ })),
152
+ skipDuplicates: true,
153
+ });
154
+ expect(res).toEqual(result);
155
+ });
156
+ });
157
+ describe('listRoles', () => {
158
+ it('should call paginate method with correct parameters', async () => {
159
+ const locale = 'en';
160
+ const routeId = 1;
161
+ const paginationParams = {
162
+ page: 1,
163
+ pageSize: 10,
164
+ search: '',
165
+ sortField: '',
166
+ sortOrder: pagination_1.PageOrderDirection.Asc,
167
+ fields: '',
168
+ };
169
+ paginationService.paginate = jest.fn().mockResolvedValue({
170
+ data: [],
171
+ total: 0,
172
+ });
173
+ await service.listRoles(locale, routeId, paginationParams);
174
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.roles, paginationParams, {
175
+ include: {
176
+ role_translations: {
177
+ where: {
178
+ locales: { code: locale },
179
+ },
180
+ select: {
181
+ name: true,
182
+ description: true,
183
+ },
184
+ },
185
+ role_routes: {
186
+ where: { route_id: routeId },
187
+ select: {
188
+ route_id: true,
189
+ role_id: true,
190
+ },
191
+ },
192
+ },
193
+ }, 'role_translations');
194
+ });
195
+ });
196
+ describe('listScreens', () => {
197
+ it('should call paginate method with correct parameters', async () => {
198
+ const locale = 'en';
199
+ const routeId = 1;
200
+ const paginationParams = {
201
+ page: 1,
202
+ pageSize: 10,
203
+ search: '',
204
+ sortField: '',
205
+ sortOrder: pagination_1.PageOrderDirection.Asc,
206
+ fields: '',
207
+ };
208
+ paginationService.paginate = jest.fn().mockResolvedValue({
209
+ data: [],
210
+ total: 0,
211
+ });
212
+ await service.listScreens(locale, routeId, paginationParams);
213
+ expect(paginationService.paginate).toHaveBeenCalledWith(prismaService.screens, paginationParams, {
214
+ include: {
215
+ screen_translations: {
216
+ where: {
217
+ locales: { code: locale },
218
+ },
219
+ select: {
220
+ name: true,
221
+ },
222
+ },
223
+ route_screens: {
224
+ where: { route_id: routeId },
225
+ select: {
226
+ route_id: true,
227
+ screen_id: true,
228
+ },
229
+ },
230
+ },
231
+ }, 'screen_translations');
232
+ });
233
+ });
234
+ });
235
+ //# sourceMappingURL=route.service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.service.spec.js","sourceRoot":"","sources":["../../src/route/route.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,mDAI4B;AAC5B,2CAA+C;AAC/C,mDAA+C;AAM/C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,OAAqB,CAAC;IAC1B,IAAI,aAA4B,CAAC;IACjC,IAAI,iBAAoC,CAAC;IAEzC,MAAM,iBAAiB,GAAG;QACxB,MAAM,EAAE;YACN,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;YACrB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;YACjB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;YACjB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;SACtB;QACD,WAAW,EAAE;YACX,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;YACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;SACtB;QACD,aAAa,EAAE;YACb,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;YACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE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AAI;yBACX;qBACF;oBACD,aAAa,EAAE;wBACb,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE;wBAC5B,MAAM,EAAE;4BACN,QAAQ,EAAE,IAAI;4BACd,SAAS,EAAE,IAAI;yBAChB;qBACF;iBACF;aACF,EACD,qBAAqB,CACtB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=screen.service.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.service.spec.d.ts","sourceRoot":"","sources":["../../src/screen/screen.service.spec.ts"],"names":[],"mappings":""}