Skip to content

Commit

Permalink
Update tests to work with new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
david-rocca committed Jan 7, 2025
1 parent 454304b commit 2b0771c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/integration-tests/cve/cursorPaginationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('Testing Get cve_cursor endpoint', () => {
// Request page 2
await requester.get('/api/cve_cursor?limit=2&next_page=' + next + '&time_modified.lt=' + currentDate)
.set(constants.headers)
.then((res, err) => {
.then(async (res, err) => {
expect(err).to.be.undefined
expect(res).to.have.status(200)

Expand Down
4 changes: 2 additions & 2 deletions test/integration-tests/org/postOrgUsersTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ describe('Testing user post endpoint', () => {
expect(err).to.be.undefined
})
})
it('Fails creation of user for trying to add the 101th user', async () => {
it('Fails creation of user for trying to add the 101th user', async function () {
this.timeout(7000)
const numberOfUsers = await User.where({ org_UUID: orgUuid }).countDocuments().exec()
for (let i = 0; i < (100 - numberOfUsers); i++) {
const newUser = new User()
Expand All @@ -156,7 +157,6 @@ describe('Testing user post endpoint', () => {
'ADMIN'
]
}

await User.findOneAndUpdate().byUserNameAndOrgUUID(newUser.userName, newUser.org_UUID).updateOne(newUser).setOptions({ upsert: true })
}

Expand Down
31 changes: 18 additions & 13 deletions test/unit-tests/org/orgGetIdQuotaTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,29 @@ describe('Testing the GET /org/:shortname/id_quota endpoint in Org Controller',
context('Negative Tests', () => {
it('Org with a negative id_quota was not saved', (done) => {
const org = new Org(orgFixtures.orgWithNegativeIdQuota)

org.validate((err) => {
const CONSTANTS = getConstants()

expect(err.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_min_message)
done()
})
org.save()
.then(() => {
expect(false)
})
.catch((error) => {
const CONSTANTS = getConstants()
expect(error.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_min_message)
})
done()
})

it('Org with an id_quota greater than the max was not saved', (done) => {
const org = new Org(orgFixtures.orgExceedingMaxIdQuota)

org.validate((err) => {
const CONSTANTS = getConstants()

expect(err.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max_message)
done()
})
org.save()
.then(() => {
expect(false)
})
.catch((error) => {
const CONSTANTS = getConstants()
expect(error.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max_message)
})
done()
})

it('Requestor is not secretariat or a user of the same org', (done) => {
Expand Down

0 comments on commit 2b0771c

Please sign in to comment.