Skip to content

Commit 530ec24

Browse files
committed
Update tests to work with new syntax
1 parent 1cedccd commit 530ec24

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

test/integration-tests/cve/cursorPaginationTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('Testing Get cve_cursor endpoint', () => {
156156
// Request page 2
157157
await requester.get('/api/cve_cursor?limit=2&next_page=' + next + '&time_modified.lt=' + currentDate)
158158
.set(constants.headers)
159-
.then((res, err) => {
159+
.then(async (res, err) => {
160160
expect(err).to.be.undefined
161161
expect(res).to.have.status(200)
162162

test/integration-tests/org/postOrgUsersTest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ describe('Testing user post endpoint', () => {
138138
expect(err).to.be.undefined
139139
})
140140
})
141-
it('Fails creation of user for trying to add the 101th user', async () => {
141+
it('Fails creation of user for trying to add the 101th user', async function () {
142+
this.timeout(7000)
142143
const numberOfUsers = await User.where({ org_UUID: orgUuid }).countDocuments().exec()
143144
for (let i = 0; i < (100 - numberOfUsers); i++) {
144145
const newUser = new User()
@@ -156,7 +157,6 @@ describe('Testing user post endpoint', () => {
156157
'ADMIN'
157158
]
158159
}
159-
160160
await User.findOneAndUpdate().byUserNameAndOrgUUID(newUser.userName, newUser.org_UUID).updateOne(newUser).setOptions({ upsert: true })
161161
}
162162

test/unit-tests/org/orgGetIdQuotaTest.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,29 @@ describe('Testing the GET /org/:shortname/id_quota endpoint in Org Controller',
2323
context('Negative Tests', () => {
2424
it('Org with a negative id_quota was not saved', (done) => {
2525
const org = new Org(orgFixtures.orgWithNegativeIdQuota)
26-
27-
org.validate((err) => {
28-
const CONSTANTS = getConstants()
29-
30-
expect(err.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_min_message)
31-
done()
32-
})
26+
org.save()
27+
.then(() => {
28+
expect(false)
29+
})
30+
.catch((error) => {
31+
const CONSTANTS = getConstants()
32+
expect(error.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_min_message)
33+
})
34+
done()
3335
})
3436

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

38-
org.validate((err) => {
39-
const CONSTANTS = getConstants()
40-
41-
expect(err.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max_message)
42-
done()
43-
})
40+
org.save()
41+
.then(() => {
42+
expect(false)
43+
})
44+
.catch((error) => {
45+
const CONSTANTS = getConstants()
46+
expect(error.errors['policies.id_quota'].message).to.equal(CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max_message)
47+
})
48+
done()
4449
})
4550

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

0 commit comments

Comments
 (0)