Skip to content

Commit

Permalink
chore: fixed backend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Sep 20, 2023
1 parent 45a7c21 commit 613111c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/test/events.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash'
import chai, { util, expect } from 'chai'
import chailint from 'chai-lint'
import request from 'superagent'
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('events', () => {
checkAuthorisation: true
})
expect(authorisation).toExist()
users = await userService.find({ query: { 'profile.name': orgUserObject.name }, checkAuthorisation: true, user: orgManagerObject })
users = await userService.find({ query: { 'profile.name': _.get(orgUserObject, 'profile.name') }, checkAuthorisation: true, user: orgManagerObject })
expect(users.data.length > 0).beTrue()
// Update user with authorisations
orgUserObject = users.data[0]
Expand Down Expand Up @@ -356,7 +357,7 @@ describe('events', () => {
checkAuthorisation: true
})
expect(authorisation).toExist()
const users = await userService.find({ query: { 'profile.name': userObject.name }, checkAuthorisation: true, user: orgManagerObject })
const users = await userService.find({ query: { 'profile.name': _.get(userObject, 'profile.name') }, checkAuthorisation: true, user: orgManagerObject })
expect(users.data.length > 0).beTrue()
// Update user with authorisations
userObject = users.data[0]
Expand Down Expand Up @@ -498,15 +499,15 @@ describe('events', () => {

it('removes test user', async () => {
await userService.remove(userObject._id, { user: userObject, checkAuthorisation: true })
const users = await userService.find({ query: { name: userObject.name }, user: userObject, checkAuthorisation: true })
const users = await userService.find({ query: { 'profile.name': _.get(userObject, 'profile.name') }, user: userObject, checkAuthorisation: true })
expect(users.data.length === 0).beTrue()
})
// Let enough time to process
.timeout(5000)

it('removes org user', async () => {
await userService.remove(orgUserObject._id, { user: orgUserObject, checkAuthorisation: true })
const users = await userService.find({ query: { name: orgUserObject.name }, user: orgUserObject, checkAuthorisation: true })
const users = await userService.find({ query: { 'profile.name': _.get(orgUserObject, 'profile.name') }, user: orgUserObject, checkAuthorisation: true })
expect(users.data.length === 0).beTrue()
})
// Let enough time to process
Expand All @@ -533,7 +534,7 @@ describe('events', () => {

it('removes org manager', async () => {
await userService.remove(orgManagerObject._id, { user: orgManagerObject, checkAuthorisation: true })
const users = await userService.find({ query: { name: orgManagerObject.name }, user: orgManagerObject, checkAuthorisation: true })
const users = await userService.find({ query: { 'profile.name': _.get(orgManagerObject, 'profile.name') }, user: orgManagerObject, checkAuthorisation: true })
expect(users.data.length === 0).beTrue()
})
// Let enough time to process
Expand Down

0 comments on commit 613111c

Please sign in to comment.