Made test chains prettier
parent
bfaa034467
commit
2d5e6ba948
41
test/auth.js
41
test/auth.js
|
@ -92,7 +92,7 @@ describe('Authentication', () => {
|
||||||
// Load password page
|
// Load password page
|
||||||
chai.expect(await request
|
chai.expect(await request
|
||||||
.get(`/account/password/${passwordless_user.auth.passToken}`)
|
.get(`/account/password/${passwordless_user.auth.passToken}`)
|
||||||
).html.to.have.status(200)
|
).to.be.html.and.have.status(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Fails to set a weak password', async () => {
|
it('Fails to set a weak password', async () => {
|
||||||
|
@ -103,26 +103,25 @@ describe('Authentication', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Sets a strong password', async () => {
|
it('Sets a strong password', async () => {
|
||||||
try {
|
|
||||||
|
|
||||||
// Perform request
|
// Perform request
|
||||||
let res = await request
|
let res = await request
|
||||||
.post(`/account/password/${passwordless_user.auth.passToken}`)
|
.post(`/account/password/${passwordless_user.auth.passToken}`)
|
||||||
.type('form').send({ 'password':TEST_PASSWORD })
|
.type('form').send({ 'password':TEST_PASSWORD })
|
||||||
|
|
||||||
// Expect redirect
|
// Expect redirect
|
||||||
chai.expect(res).to.redirectTo('/login')
|
chai.expect(res).to.redirectTo('/login')
|
||||||
|
|
||||||
// Retrieve user with password saved
|
// Retrieve user with password saved
|
||||||
let passworded_user = await User.findOne({'email':TEST_EMAIL} )
|
let passworded_user = await User.findOne({'email':TEST_EMAIL} )
|
||||||
|
|
||||||
// Assert password was set
|
// Assert password was set
|
||||||
chai.assert.isString(
|
chai.assert.isString(
|
||||||
passworded_user.auth.password, 'Failed to correctly save password'
|
passworded_user.auth.password, 'Failed to correctly save password'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
return res
|
|
||||||
} catch (err) { throw err }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// These tests require the test user to have been created
|
// These tests require the test user to have been created
|
||||||
|
@ -161,7 +160,7 @@ describe('Authentication', () => {
|
||||||
|
|
||||||
it('Loads forgot password page', async () => {
|
it('Loads forgot password page', async () => {
|
||||||
let res = await request.get('/login/forgot')
|
let res = await request.get('/login/forgot')
|
||||||
chai.expect(res).html.to.have.status(200)
|
chai.expect(res).to.be.html.and.have.status(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Test already-logged-in forgot password requests
|
// TODO: Test already-logged-in forgot password requests
|
||||||
|
@ -169,14 +168,14 @@ describe('Authentication', () => {
|
||||||
// TODO: Test invalid and fuzzed forgot password requests
|
// TODO: Test invalid and fuzzed forgot password requests
|
||||||
|
|
||||||
// TODO: Fix this test
|
// TODO: Fix this test
|
||||||
it.skip('Sends valid forgot password request', async () => {
|
it.only('Sends valid forgot password request', async () => {
|
||||||
|
|
||||||
// Responds with 200
|
// Responds with 200
|
||||||
let res = await request.post('/login/forgot')
|
chai.expect( await request.post('/login/forgot')
|
||||||
.type('form').send({
|
.type('form').send({
|
||||||
email: TEST_EMAIL,
|
'email': TEST_EMAIL,
|
||||||
})
|
})
|
||||||
chai.expect(res).html.to.have.status(200)
|
).to.be.html.and.have.status(200)
|
||||||
|
|
||||||
// Assert password was set
|
// Assert password was set
|
||||||
let requesting_user = await User.findOne({'email':TEST_EMAIL} )
|
let requesting_user = await User.findOne({'email':TEST_EMAIL} )
|
||||||
|
|
Loading…
Reference in New Issue