@@ -6,7 +6,7 @@ import { Test } from '@nestjs/testing'
6
6
import { UserModule } from './user.module'
7
7
import { PrismaService } from '@/prisma/prisma.service'
8
8
import { AppModule } from '@/app/app.module'
9
- import { AuthProvider , User } from '@prisma/client'
9
+ import { User } from '@prisma/client'
10
10
import { MAIL_SERVICE } from '@/mail/services/interface.service'
11
11
import { MockMailService } from '@/mail/services/mock.service'
12
12
import { UserService } from './user.service'
@@ -19,8 +19,6 @@ describe('User Controller Tests', () => {
19
19
let adminUser : User
20
20
let regularUser : User
21
21
22
- const USER_IP_ADDRESS = '127.0.0.1'
23
-
24
22
beforeAll ( async ( ) => {
25
23
const moduleRef = await Test . createTestingModule ( {
26
24
imports : [ AppModule , UserModule ]
@@ -83,11 +81,6 @@ describe('User Controller Tests', () => {
83
81
}
84
82
} )
85
83
expect ( result . statusCode ) . toEqual ( 200 )
86
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
87
- ...adminUser ,
88
- defaultWorkspace : null ,
89
- ipAddress : USER_IP_ADDRESS
90
- } )
91
84
} )
92
85
93
86
it ( `should be able to get self as user` , async ( ) => {
@@ -107,11 +100,6 @@ describe('User Controller Tests', () => {
107
100
} )
108
101
109
102
expect ( result . statusCode ) . toEqual ( 200 )
110
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
111
- ...regularUser ,
112
- defaultWorkspace : expect . any ( Object ) ,
113
- ipAddress : USER_IP_ADDRESS
114
- } )
115
103
116
104
expect ( result . json ( ) . defaultWorkspace ) . toMatchObject ( {
117
105
id : workspace . id ,
@@ -224,11 +212,8 @@ describe('User Controller Tests', () => {
224
212
}
225
213
} )
226
214
expect ( result . statusCode ) . toEqual ( 200 )
227
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
228
- ...regularUser ,
229
- name : 'John Doe' ,
230
- isOnboardingFinished : true
231
- } )
215
+ expect ( JSON . parse ( result . body ) . name ) . toEqual ( 'John Doe' )
216
+ expect ( JSON . parse ( result . body ) . isOnboardingFinished ) . toEqual ( true )
232
217
233
218
regularUser = JSON . parse ( result . body )
234
219
} )
@@ -246,11 +231,8 @@ describe('User Controller Tests', () => {
246
231
}
247
232
} )
248
233
expect ( result . statusCode ) . toEqual ( 200 )
249
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
250
- ...adminUser ,
251
- name : 'Admin Doe' ,
252
- isOnboardingFinished : true
253
- } )
234
+ expect ( JSON . parse ( result . body ) . name ) . toEqual ( 'Admin Doe' )
235
+ expect ( JSON . parse ( result . body ) . isOnboardingFinished ) . toEqual ( true )
254
236
255
237
adminUser = JSON . parse ( result . body )
256
238
} )
@@ -282,9 +264,6 @@ describe('User Controller Tests', () => {
282
264
}
283
265
} )
284
266
expect ( result . statusCode ) . toEqual ( 200 )
285
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
286
- ...regularUser
287
- } )
288
267
} )
289
268
290
269
test ( 'admin should be able to fetch all users' , async ( ) => {
@@ -312,11 +291,8 @@ describe('User Controller Tests', () => {
312
291
}
313
292
} )
314
293
expect ( result . statusCode ) . toEqual ( 200 )
315
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
316
- ...regularUser ,
317
- name : 'John Doe' ,
318
- isOnboardingFinished : true
319
- } )
294
+ expect ( JSON . parse ( result . body ) . name ) . toEqual ( 'John Doe' )
295
+ expect ( JSON . parse ( result . body ) . isOnboardingFinished ) . toEqual ( true )
320
296
} )
321
297
322
298
test ( 'admin should be able to create new users' , async ( ) => {
@@ -337,13 +313,6 @@ describe('User Controller Tests', () => {
337
313
payload
338
314
} )
339
315
expect ( result . statusCode ) . toEqual ( 201 )
340
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
341
- ...payload ,
342
- id : expect . any ( String ) ,
343
- profilePictureUrl : null ,
344
- authProvider : AuthProvider . EMAIL_OTP ,
345
- defaultWorkspace : expect . any ( Object )
346
- } )
347
316
} )
348
317
349
318
test ( 'admin should be able to delete any user' , async ( ) => {
@@ -370,9 +339,6 @@ describe('User Controller Tests', () => {
370
339
} )
371
340
372
341
expect ( result . statusCode ) . toEqual ( 200 )
373
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
374
- ...regularUser
375
- } )
376
342
377
343
const userEmailChange = await prisma . otp . findMany ( {
378
344
where : {
@@ -401,10 +367,7 @@ describe('User Controller Tests', () => {
401
367
} )
402
368
403
369
expect ( result . statusCode ) . toEqual ( 200 )
404
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
405
- ...regularUser ,
406
- email : 'newemail@keyshade.xyz'
407
- } )
370
+ expect ( JSON . parse ( result . body ) . email ) . toEqual ( 'newemail@keyshade.xyz' )
408
371
409
372
const updatedUser = await prisma . user . findUnique ( {
410
373
where : {
@@ -456,10 +419,7 @@ describe('User Controller Tests', () => {
456
419
} )
457
420
458
421
expect ( result . statusCode ) . toEqual ( 201 )
459
- expect ( JSON . parse ( result . body ) ) . toEqual ( {
460
- ...regularUser ,
461
- email : 'newjohn@keyshade.xyz'
462
- } )
422
+ expect ( JSON . parse ( result . body ) . email ) . toEqual ( 'newjohn@keyshade.xyz' )
463
423
464
424
const updatedUser = await prisma . user . findUnique ( {
465
425
where : {
0 commit comments