Skip to content

Commit 833b798

Browse files
committed
Add tests
1 parent 7259e1c commit 833b798

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

test/integration/metadataAPITests.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {ClientModelAPI} from '../../src/model/clients'
1616
import {ContactGroupModelAPI} from '../../src/model/contactGroups'
1717
import {MediatorModelAPI} from '../../src/model/mediators'
1818
import {UserModelAPI} from '../../src/model/users'
19+
import {PassportModelAPI} from '../../src/model/passport'
1920
import * as polling from '../../src/polling'
2021

2122
const sampleMetadata = {
@@ -89,6 +90,12 @@ const sampleMetadata = {
8990
groups: ['admin', 'RHIE']
9091
}
9192
],
93+
Passports: [
94+
{
95+
96+
protocol: 'local'
97+
}
98+
],
9299
ContactGroups: [
93100
{
94101
group: 'Group 1',
@@ -112,6 +119,7 @@ describe('API Integration Tests', () => {
112119
nonRootCookie = ''
113120

114121
before(async () => {
122+
await PassportModelAPI.deleteMany({})
115123
await promisify(server.start)({apiPort: SERVER_PORTS.apiPort})
116124
await testUtils.setupTestUsers()
117125
})
@@ -216,6 +224,17 @@ describe('API Integration Tests', () => {
216224
})
217225
})
218226

227+
describe('Passports', () => {
228+
it('should fetch passports and return status 200', async () => {
229+
const res = await request(BASE_URL)
230+
.get('/metadata')
231+
.set('Cookie', rootCookie)
232+
.expect(200)
233+
234+
res.body[0].Passports.length.should.equal(2)
235+
})
236+
})
237+
219238
describe('ContactGroups', () => {
220239
beforeEach(async () => {
221240
await new ContactGroupModelAPI(sampleMetadata.ContactGroups[0]).save()
@@ -724,11 +743,14 @@ describe('API Integration Tests', () => {
724743
// POST TO VALIDATE METADATA TESTS
725744
describe('*validateMetadata', () => {
726745
beforeEach(async () => {
746+
await PassportModelAPI.deleteMany()
727747
await testUtils.cleanupAllTestUsers()
728748
await testUtils.setupTestUsers()
729749
})
730750

731751
it('should validate metadata and return status 201', async () => {
752+
const im = await PassportModelAPI.find()
753+
732754
const res = await request(BASE_URL)
733755
.post('/metadata/validate')
734756
.set('Cookie', rootCookie)
@@ -741,7 +763,7 @@ describe('API Integration Tests', () => {
741763
statusCheckObj[doc.status] += 1
742764
}
743765

744-
statusCheckObj.Valid.should.equal(5)
766+
statusCheckObj.Valid.should.equal(6)
745767
statusCheckObj.Conflict.should.equal(0)
746768
statusCheckObj.Error.should.equal(0)
747769
})
@@ -762,7 +784,7 @@ describe('API Integration Tests', () => {
762784
statusCheckObj[doc.status] += 1
763785
}
764786

765-
statusCheckObj.Valid.should.equal(4)
787+
statusCheckObj.Valid.should.equal(5)
766788
statusCheckObj.Conflict.should.equal(0)
767789
statusCheckObj.Error.should.equal(1)
768790
})
@@ -787,7 +809,7 @@ describe('API Integration Tests', () => {
787809
statusCheckObj[doc.status] += 1
788810
}
789811

790-
statusCheckObj.Valid.should.equal(4)
812+
statusCheckObj.Valid.should.equal(5)
791813
statusCheckObj.Conflict.should.equal(1)
792814
statusCheckObj.Error.should.equal(0)
793815
ChannelModelAPI.deleteMany({})

test/unit/metadataTest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ describe('Metadata Functions', () => {
4242
})
4343
result.should.have.property('urn', 'mediatorUID')
4444

45+
result = metadata.getUniqueIdentifierForCollection('Passports', {
46+
email: 'userEmail',
47+
protocol: 'local'
48+
})
49+
result.should.have.property('email', 'userEmail')
50+
result.should.have.property('protocol', 'local')
51+
4552
result = metadata.getUniqueIdentifierForCollection('Users', {
4653
email: 'userUID'
4754
})

0 commit comments

Comments
 (0)