Skip to content

Commit

Permalink
Update user.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Nov 17, 2024
1 parent 95b1aba commit 8f7a1af
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions api/tests/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,24 @@ describe('POST /api/delete-users', () => {
it('should delete users', async () => {
const token = await testHelper.signinAsAdmin()

let payload: string[] = [USER1_ID, USER2_ID, ADMIN_ID]
const supplierName1 = testHelper.getSupplierName()
const supplier1Id = await testHelper.createSupplier(`${supplierName1}@test.bookcars.ma`, supplierName1)

const supplierName2 = testHelper.getSupplierName()
const supplier2Id = await testHelper.createSupplier(`${supplierName2}@test.bookcars.ma`, supplierName1)
const supplier2 = await User.findById(supplier2Id)
supplier2!.contracts = [
{ language: 'en', file: null },
{ language: 'fr', file: `${nanoid()}.pdf` },
]
await supplier2?.save()

let payload: string[] = [USER1_ID, USER2_ID, ADMIN_ID, supplier1Id, supplier2Id]
const user1 = await User.findById(USER1_ID)
user1!.avatar = `${nanoid()}.jpg`
await user1?.save()
let users = await User.find({ _id: { $in: payload } })
expect(users.length).toBe(3)
expect(users.length).toBe(5)
let res = await request(app)
.post('/api/delete-users')
.set(env.X_ACCESS_TOKEN, token)
Expand Down

0 comments on commit 8f7a1af

Please sign in to comment.