Skip to content

Commit

Permalink
add: add test for new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslav-fedyshyn-nordwhale committed Oct 2, 2019
1 parent 508357c commit e5f3b72
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/server/verification/__tests__/verificationAPI.js
Expand Up @@ -63,6 +63,20 @@ describe('verificationAPI', () => {
.expect(200, { ok: 1, onlyInEnv: { current: 'test', onlyIn: ['production', 'staging'] } })
})

test('/verify/sendnewotp without creds -> 401', async () => {
await request(server)
.post('/verify/sendnewotp')
.expect(401)
})

test('/verify/sendnewotp with creds', async () => {
const token = await getToken(server)
await request(server)
.post('/verify/sendnewotp')
.set('Authorization', `Bearer ${token}`)
.expect(200, { ok: 1, onlyInEnv: { current: 'test', onlyIn: ['production', 'staging'] } })
})

test('/verify/sendemail with creds', async () => {
const token = await getToken(server)

Expand All @@ -76,20 +90,17 @@ describe('verificationAPI', () => {
expect(user).toBeTruthy()

await request(server)
.post('/verify/sendemail')
.post('/verify/sendnewemail')
.send({
user: {
fullName: 'h r',
email: 'johndoe@gooddollar.org'
}
email: 'johndoe@gooddollar.org'
})
.set('Authorization', `Bearer ${token}`)
.expect(200, { ok: 1 })
await delay(500)

await delay(1000)

const dbUser = await UserDBPrivate.getUser('0x7ac080f6607405705aed79675789701a48c76f55')

expect(dbUser.mauticId).toBeTruthy()
expect(dbUser.emailVerificationCode).toBeTruthy()
})

Expand Down

0 comments on commit e5f3b72

Please sign in to comment.