@hedhog/admin 0.12.1 → 0.12.3
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.
- package/{hedhog.yaml → bkp.hedhog.yaml} +207 -9
- package/dist/auth/auth.controller.d.ts +1 -10
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.service.d.ts +1 -10
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/auth.service.spec.d.ts +0 -1
- package/dist/auth/auth.service.spec.js +171 -161
- package/dist/auth/auth.service.spec.js.map +1 -1
- package/dist/menu/menu.controller.d.ts +6 -33
- package/dist/menu/menu.controller.d.ts.map +1 -1
- package/dist/menu/menu.service.d.ts +6 -33
- package/dist/menu/menu.service.d.ts.map +1 -1
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/role/role.controller.d.ts +5 -5
- package/dist/role/role.service.d.ts +5 -5
- package/dist/role/role.service.js.map +1 -1
- package/dist/route/route.controller.d.ts +6 -27
- package/dist/route/route.controller.d.ts.map +1 -1
- package/dist/route/route.service.d.ts +6 -27
- package/dist/route/route.service.d.ts.map +1 -1
- package/dist/route/route.service.js.map +1 -1
- package/dist/screen/screen.controller.d.ts +6 -24
- package/dist/screen/screen.controller.d.ts.map +1 -1
- package/dist/screen/screen.service.d.ts +6 -24
- package/dist/screen/screen.service.d.ts.map +1 -1
- package/dist/screen/screen.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +5 -32
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.service.d.ts +5 -32
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js.map +1 -1
- package/dist/user/user.service.spec.d.ts +0 -1
- package/dist/user/user.service.spec.js +259 -250
- package/dist/user/user.service.spec.js.map +1 -1
- package/frontend/menu/components/create-panel.tsx.ejs +55 -0
- package/frontend/menu/components/update-panel.tsx.ejs +67 -0
- package/frontend/menu/locales/en/admin.menu.json +11 -0
- package/frontend/menu/locales/pt/admin.menu.json +11 -0
- package/frontend/menu/react-query/handlers.ts.ejs +28 -0
- package/frontend/menu/react-query/requests.ts.ejs +56 -0
- package/frontend/menu-locale/locales/en/admin.menu-locale.json +11 -0
- package/frontend/menu-locale/locales/pt/admin.menu-locale.json +11 -0
- package/frontend/menu-screen/locales/en/admin.menu-screen.json +11 -0
- package/frontend/menu-screen/locales/pt/admin.menu-screen.json +11 -0
- package/frontend/multifactor/components/create-panel.tsx.ejs +55 -0
- package/frontend/multifactor/components/update-panel.tsx.ejs +70 -0
- package/frontend/multifactor/locales/en/admin.multifactor.json +11 -0
- package/frontend/multifactor/locales/pt/admin.multifactor.json +11 -0
- package/frontend/multifactor/react-query/handlers.ts.ejs +28 -0
- package/frontend/multifactor/react-query/requests.ts.ejs +59 -0
- package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +11 -0
- package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +11 -0
- package/frontend/screen/components/create-panel.tsx.ejs +55 -0
- package/frontend/screen/components/update-panel.tsx.ejs +67 -0
- package/frontend/screen/locales/en/admin.screen.json +11 -0
- package/frontend/screen/locales/pt/admin.screen.json +11 -0
- package/frontend/screen/react-query/handlers.ts.ejs +28 -0
- package/frontend/screen/react-query/requests.ts.ejs +56 -0
- package/frontend/screen-locale/locales/en/admin.screen-locale.json +11 -0
- package/frontend/screen-locale/locales/pt/admin.screen-locale.json +11 -0
- package/frontend/translation/components/create-panel.tsx.ejs +52 -0
- package/frontend/translation/components/update-panel.tsx.ejs +67 -0
- package/frontend/translation/fields/en.json +1 -0
- package/frontend/translation/fields/pt.json +1 -0
- package/frontend/translation/locales/en/admin.translation.json +11 -0
- package/frontend/translation/locales/pt/admin.translation.json +11 -0
- package/frontend/translation/modules/en.json +1 -0
- package/frontend/translation/modules/pt.json +1 -0
- package/frontend/translation/react-query/handlers.ts.ejs +28 -0
- package/frontend/translation/react-query/requests.ts.ejs +58 -0
- package/frontend/translation-namespace/components/create-panel.tsx.ejs +53 -0
- package/frontend/translation-namespace/components/update-panel.tsx.ejs +70 -0
- package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +11 -0
- package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +11 -0
- package/frontend/translation-namespace/react-query/handlers.ts.ejs +28 -0
- package/frontend/translation-namespace/react-query/requests.ts.ejs +60 -0
- package/frontend/user/components/create-panel.tsx.ejs +52 -0
- package/frontend/user/components/update-panel.tsx.ejs +64 -0
- package/frontend/user/locales/en/admin.user.json +11 -0
- package/frontend/user/locales/pt/admin.user.json +11 -0
- package/frontend/user/react-query/handlers.ts.ejs +28 -0
- package/frontend/user/react-query/requests.ts.ejs +55 -0
- package/package.json +43 -43
- package/src/auth/auth.service.spec.ts +196 -196
- package/src/auth/auth.service.ts +10 -10
- package/src/menu/menu.service.ts +16 -16
- package/src/role/guards/role.guard.ts +2 -2
- package/src/role/role.service.ts +17 -17
- package/src/route/route.service.ts +13 -13
- package/src/screen/screen.service.ts +14 -14
- package/src/user/user.service.spec.ts +294 -294
- package/src/user/user.service.ts +10 -10
@@ -1,294 +1,294 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
} from '@hedhog/pagination';
|
6
|
-
import { PrismaService } from '@hedhog/prisma';
|
7
|
-
import { BadRequestException } from '@nestjs/common';
|
8
|
-
import { Test, TestingModule } from '@nestjs/testing';
|
9
|
-
import { genSalt, hash } from 'bcrypt';
|
10
|
-
import { DeleteDTO } from '../dto/delete.dto';
|
11
|
-
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
12
|
-
import { SALT_ROUNDS } from './constants/user.constants';
|
13
|
-
import { CreateDTO } from './dto/create.dto';
|
14
|
-
import { UpdateDTO } from './dto/update.dto';
|
15
|
-
import { UserService } from './user.service';
|
16
|
-
|
17
|
-
jest.mock('bcrypt', () => ({
|
18
|
-
|
19
|
-
|
20
|
-
}));
|
21
|
-
|
22
|
-
describe('UserService', () => {
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
*/
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
});
|
1
|
+
// import {
|
2
|
+
// PageOrderDirection,
|
3
|
+
// PaginationDTO,
|
4
|
+
// PaginationService,
|
5
|
+
// } from '@hedhog/pagination';
|
6
|
+
// import { PrismaService } from '@hedhog/prisma';
|
7
|
+
// import { BadRequestException } from '@nestjs/common';
|
8
|
+
// import { Test, TestingModule } from '@nestjs/testing';
|
9
|
+
// import { genSalt, hash } from 'bcrypt';
|
10
|
+
// import { DeleteDTO } from '../dto/delete.dto';
|
11
|
+
// import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
12
|
+
// import { SALT_ROUNDS } from './constants/user.constants';
|
13
|
+
// import { CreateDTO } from './dto/create.dto';
|
14
|
+
// import { UpdateDTO } from './dto/update.dto';
|
15
|
+
// import { UserService } from './user.service';
|
16
|
+
|
17
|
+
// jest.mock('bcrypt', () => ({
|
18
|
+
// genSalt: jest.fn().mockResolvedValue('mockSalt'),
|
19
|
+
// hash: jest.fn().mockResolvedValue('mockHashedPassword'),
|
20
|
+
// }));
|
21
|
+
|
22
|
+
// describe('UserService', () => {
|
23
|
+
// let service: UserService;
|
24
|
+
// let prismaService: PrismaService;
|
25
|
+
// let paginationService: PaginationService;
|
26
|
+
|
27
|
+
// beforeEach(async () => {
|
28
|
+
// const module: TestingModule = await Test.createTestingModule({
|
29
|
+
// providers: [
|
30
|
+
// UserService,
|
31
|
+
// {
|
32
|
+
// provide: PrismaService,
|
33
|
+
// useValue: {
|
34
|
+
// user: {
|
35
|
+
// findUnique: jest.fn(),
|
36
|
+
// create: jest.fn(),
|
37
|
+
// update: jest.fn(),
|
38
|
+
// deleteMany: jest.fn(),
|
39
|
+
// },
|
40
|
+
// role_user: {
|
41
|
+
// deleteMany: jest.fn(),
|
42
|
+
// createMany: jest.fn(),
|
43
|
+
// },
|
44
|
+
// createInsensitiveSearch: jest.fn(),
|
45
|
+
// },
|
46
|
+
// },
|
47
|
+
// {
|
48
|
+
// provide: PaginationService,
|
49
|
+
// useValue: {
|
50
|
+
// paginate: jest.fn(),
|
51
|
+
// },
|
52
|
+
// },
|
53
|
+
// ],
|
54
|
+
// }).compile();
|
55
|
+
|
56
|
+
// service = module.get<UserService>(UserService);
|
57
|
+
// prismaService = module.get<PrismaService>(PrismaService);
|
58
|
+
// paginationService = module.get<PaginationService>(PaginationService);
|
59
|
+
// });
|
60
|
+
|
61
|
+
// it('should be defined', () => {
|
62
|
+
// expect(service).toBeDefined();
|
63
|
+
// });
|
64
|
+
|
65
|
+
// describe('listRoles', () => {
|
66
|
+
// it('should return paginated role for a specific user', async () => {
|
67
|
+
// const paginationParams: PaginationDTO = {
|
68
|
+
// page: 1,
|
69
|
+
// pageSize: 10,
|
70
|
+
// search: '',
|
71
|
+
// sortField: '',
|
72
|
+
// sortOrder: PageOrderDirection.Asc,
|
73
|
+
// fields: '',
|
74
|
+
// };
|
75
|
+
|
76
|
+
// const mockPaginatedRoles = {
|
77
|
+
// data: [],
|
78
|
+
// total: 10,
|
79
|
+
// lastPage: 1,
|
80
|
+
// page: 1,
|
81
|
+
// prev: 0,
|
82
|
+
// next: 2,
|
83
|
+
// pageSize: 10,
|
84
|
+
// };
|
85
|
+
|
86
|
+
// jest
|
87
|
+
// .spyOn(paginationService, 'paginate')
|
88
|
+
// .mockResolvedValue(mockPaginatedRoles);
|
89
|
+
|
90
|
+
// const result = await service.listRoles(1, paginationParams);
|
91
|
+
|
92
|
+
// expect(paginationService.paginate).toHaveBeenCalledWith(
|
93
|
+
// prismaService.role,
|
94
|
+
// paginationParams,
|
95
|
+
// {
|
96
|
+
// include: {
|
97
|
+
// role_user: {
|
98
|
+
// where: { user_id: 1 },
|
99
|
+
// select: { user_id: true, role_id: true },
|
100
|
+
// },
|
101
|
+
// },
|
102
|
+
// },
|
103
|
+
// );
|
104
|
+
// expect(result).toEqual(mockPaginatedRoles);
|
105
|
+
// });
|
106
|
+
// });
|
107
|
+
|
108
|
+
// describe('updateRoles', () => {
|
109
|
+
// it('should update user role', async () => {
|
110
|
+
// const updateIdsDTO: UpdateIdsDTO = { ids: [1, 2] };
|
111
|
+
|
112
|
+
// jest
|
113
|
+
// .spyOn(prismaService.role_user, 'deleteMany')
|
114
|
+
// .mockResolvedValue({ count: 1 });
|
115
|
+
// jest
|
116
|
+
// .spyOn(prismaService.role_user, 'createMany')
|
117
|
+
// .mockResolvedValue({ count: 2 });
|
118
|
+
|
119
|
+
// await service.updateRoles(1, updateIdsDTO);
|
120
|
+
|
121
|
+
// expect(prismaService.role_user.deleteMany).toHaveBeenCalledWith({
|
122
|
+
// where: { user_id: 1 },
|
123
|
+
// });
|
124
|
+
// expect(prismaService.role_user.createMany).toHaveBeenCalledWith({
|
125
|
+
// data: [
|
126
|
+
// { user_id: 1, role_id: 1 },
|
127
|
+
// { user_id: 1, role_id: 2 },
|
128
|
+
// ],
|
129
|
+
// skipDuplicates: true,
|
130
|
+
// });
|
131
|
+
// });
|
132
|
+
// });
|
133
|
+
// /*
|
134
|
+
// describe('getUsers', () => {
|
135
|
+
// it('should return paginated user', async () => {
|
136
|
+
// const paginationParams: PaginationDTO = {
|
137
|
+
// page: 1,
|
138
|
+
// pageSize: 10,
|
139
|
+
// search: '',
|
140
|
+
// sortField: '',
|
141
|
+
// sortOrder: PageOrderDirection.Asc,
|
142
|
+
// fields: '',
|
143
|
+
// };
|
144
|
+
|
145
|
+
// const mockPaginatedUsers = {
|
146
|
+
// data: [],
|
147
|
+
// total: 10,
|
148
|
+
// lastPage: 1,
|
149
|
+
// page: 1,
|
150
|
+
// prev: 0,
|
151
|
+
// next: 2,
|
152
|
+
// pageSize: 10,
|
153
|
+
// };
|
154
|
+
|
155
|
+
// jest.spyOn(prismaService, 'createInsensitiveSearch').mockReturnValue([]);
|
156
|
+
// jest
|
157
|
+
// .spyOn(paginationService, 'paginate')
|
158
|
+
// .mockResolvedValue(mockPaginatedUsers);
|
159
|
+
|
160
|
+
// const result = await service.getUsers(paginationParams);
|
161
|
+
|
162
|
+
// expect(prismaService.createInsensitiveSearch).toHaveBeenCalledWith(
|
163
|
+
// ['name', 'email'],
|
164
|
+
// paginationParams,
|
165
|
+
// );
|
166
|
+
// expect(paginationService.paginate).toHaveBeenCalledWith(
|
167
|
+
// prismaService.user,
|
168
|
+
// paginationParams,
|
169
|
+
// { where: { OR: [] } },
|
170
|
+
// );
|
171
|
+
// expect(result).toEqual(mockPaginatedUsers);
|
172
|
+
// });
|
173
|
+
// });
|
174
|
+
// */
|
175
|
+
// describe('get', () => {
|
176
|
+
// it('should return a specific user by ID', async () => {
|
177
|
+
// const mockUser = {
|
178
|
+
// id: 1,
|
179
|
+
// name: 'Test User',
|
180
|
+
// email: 'user@email.com',
|
181
|
+
// password: 'hashedpassword',
|
182
|
+
// created_at: new Date(),
|
183
|
+
// updated_at: new Date(),
|
184
|
+
// multifactor_id: null,
|
185
|
+
// code: null,
|
186
|
+
// };
|
187
|
+
// jest.spyOn(prismaService.user, 'findUnique').mockResolvedValue(mockUser);
|
188
|
+
|
189
|
+
// const result = await service.get(1);
|
190
|
+
|
191
|
+
// expect(prismaService.user.findUnique).toHaveBeenCalledWith({
|
192
|
+
// where: { id: 1 },
|
193
|
+
// });
|
194
|
+
// expect(result).toEqual(mockUser);
|
195
|
+
// });
|
196
|
+
// });
|
197
|
+
|
198
|
+
// describe('hashPassword', () => {
|
199
|
+
// it('should hash the password correctly', async () => {
|
200
|
+
// const password = 'plainPassword';
|
201
|
+
// const result = await service.hashPassword(password);
|
202
|
+
|
203
|
+
// expect(genSalt).toHaveBeenCalledWith(SALT_ROUNDS);
|
204
|
+
// expect(hash).toHaveBeenCalledWith(password, 'mockSalt');
|
205
|
+
// expect(result).toEqual('mockHashedPassword');
|
206
|
+
// });
|
207
|
+
// });
|
208
|
+
|
209
|
+
// describe('create', () => {
|
210
|
+
// it('should create a new user with hashed password', async () => {
|
211
|
+
// const createDTO: CreateDTO = {
|
212
|
+
// email: 'test@test.com',
|
213
|
+
// name: 'Test User',
|
214
|
+
// password: 'password123',
|
215
|
+
// };
|
216
|
+
// const mockUser = {
|
217
|
+
// id: 1,
|
218
|
+
// name: 'Test User',
|
219
|
+
// email: 'user@email.com',
|
220
|
+
// password: 'hashedpassword',
|
221
|
+
// created_at: new Date(),
|
222
|
+
// updated_at: new Date(),
|
223
|
+
// multifactor_id: null,
|
224
|
+
// code: null,
|
225
|
+
// };
|
226
|
+
|
227
|
+
// jest.spyOn(prismaService.user, 'create').mockResolvedValue(mockUser);
|
228
|
+
|
229
|
+
// const result = await service.create(createDTO);
|
230
|
+
|
231
|
+
// expect(prismaService.user.create).toHaveBeenCalledWith({
|
232
|
+
// data: {
|
233
|
+
// email: createDTO.email,
|
234
|
+
// name: createDTO.name,
|
235
|
+
// password: 'mockHashedPassword',
|
236
|
+
// },
|
237
|
+
// });
|
238
|
+
// expect(result).toEqual(mockUser);
|
239
|
+
// });
|
240
|
+
// });
|
241
|
+
|
242
|
+
// describe('update', () => {
|
243
|
+
// it('should update an existing user', async () => {
|
244
|
+
// const updateDTO: UpdateDTO = { name: 'Updated User' };
|
245
|
+
// const updateInput = { id: 1, data: updateDTO };
|
246
|
+
// const mockUser = {
|
247
|
+
// id: 1,
|
248
|
+
// name: 'Updated User',
|
249
|
+
// email: 'user@email.com',
|
250
|
+
// password: 'hashedpassword',
|
251
|
+
// created_at: new Date(),
|
252
|
+
// updated_at: new Date(),
|
253
|
+
// multifactor_id: null,
|
254
|
+
// code: null,
|
255
|
+
// };
|
256
|
+
// jest.spyOn(prismaService.user, 'update').mockResolvedValue(mockUser);
|
257
|
+
|
258
|
+
// const result = await service.update(updateInput);
|
259
|
+
|
260
|
+
// expect(prismaService.user.update).toHaveBeenCalledWith({
|
261
|
+
// where: { id: updateInput.id },
|
262
|
+
// data: updateInput.data,
|
263
|
+
// });
|
264
|
+
// expect(result).toEqual(mockUser);
|
265
|
+
// });
|
266
|
+
// });
|
267
|
+
|
268
|
+
// describe('delete', () => {
|
269
|
+
// it('should throw an error if no ids are provided', async () => {
|
270
|
+
// const deleteDTO: DeleteDTO = { ids: null };
|
271
|
+
|
272
|
+
// await expect(service.delete(deleteDTO)).rejects.toThrow(
|
273
|
+
// new BadRequestException('You must select at least one user to delete.'),
|
274
|
+
// );
|
275
|
+
// });
|
276
|
+
|
277
|
+
// it('should delete user by ids', async () => {
|
278
|
+
// const deleteDTO: DeleteDTO = { ids: [1, 2] };
|
279
|
+
|
280
|
+
// jest
|
281
|
+
// .spyOn(prismaService.user, 'deleteMany')
|
282
|
+
// .mockResolvedValue({ count: 2 });
|
283
|
+
|
284
|
+
// await service.delete(deleteDTO);
|
285
|
+
|
286
|
+
// expect(prismaService.user.deleteMany).toHaveBeenCalledWith({
|
287
|
+
// where: {
|
288
|
+
// id: { in: deleteDTO.ids },
|
289
|
+
// email: { not: { startsWith: 'root@' } },
|
290
|
+
// },
|
291
|
+
// });
|
292
|
+
// });
|
293
|
+
// });
|
294
|
+
// });
|