Skip to content

Commit

Permalink
Added providwer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
serdiukov-o-nordwhale committed Jun 1, 2020
1 parent 8930172 commit 5886ed8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/server/verification/api/__tests__/__util__/index.js
Expand Up @@ -99,7 +99,7 @@ export default zoomServiceMock => {
data: {
createdDate: '2019-09-16T17:30:40+00:00',
enrollmentIdentifier,
faceMap: Buffer.alloc(32),
faceMap: Buffer.alloc(32).toString(),
auditTrailImage: 'data:image/png:FaKEimagE==',
faceMapType: 0
}
Expand Down
Expand Up @@ -145,56 +145,19 @@ describe('ZoomProvider', () => {
await testEnrollmentServiceError('Network Error')
})

test('enrollmentExists() checks existing enrollment', async () => {
zoomServiceMock.onGet(helper.enrollmentUri(enrollmentIdentifier)).reply(200, {
meta: {
ok: true,
code: 200,
mode: 'dev',
message: 'A FaceMap was found for that enrollmentIdentifier.'
},
data: {
enrollmentIdentifier,
createDate: '2017-01-01T00:00:00+00:00',
auditTrailImage: 'data:image/png:FaKEimagE==',
faceMap: Buffer.alloc(32).toString(),
faceMapType: 0
}
})

test('enrollmentExists() checks enrollment existence', async () => {
helper.mockEnrollmentFound(enrollmentIdentifier)
await expect(ZoomProvider.enrollmentExists(enrollmentIdentifier)).resolves.toBe(true)
})

test('enrollmentExists() checks non-existing enrollment and not throws, just returns false', async () => {
zoomServiceMock.onGet(helper.enrollmentUri(enrollmentIdentifier)).reply(400, {
meta: {
ok: true,
code: 400,
mode: 'dev',
message: 'No entry found in the database for this enrollmentIdentifier.',
subCode: 'facemapNotFound'
}
})

helper.mockEnrollmentNotFound(enrollmentIdentifier)
await expect(ZoomProvider.enrollmentExists(enrollmentIdentifier)).resolves.toBe(false)
})

test('dispose() removes existing enrollment', async () => {
zoomServiceMock.onDelete(helper.enrollmentUri(enrollmentIdentifier)).reply(200, {
meta: {
ok: true,
code: 200,
mode: 'dev',
message: 'The entry in the database for this enrollmentIdentifier was successfully deleted.'
}
})

test("dispose() removes existing enrollment, doesn't throws for unexisting", async () => {
helper.mockEnrollmentFound(enrollmentIdentifier)
await expect(ZoomProvider.dispose(enrollmentIdentifier)).resolves.toBeUndefined()
})

test('dispose() not throws trying to remove non-existing enrollment', async () => {
helper.mockFailedRemoval(enrollmentIdentifier)

helper.mockEnrollmentNotFound(enrollmentIdentifier)
await expect(ZoomProvider.dispose(enrollmentIdentifier)).resolves.toBeUndefined()
})
})

0 comments on commit 5886ed8

Please sign in to comment.