user-managements-node-server
Version:
starter for express node server with user managements, authentication authorization
39 lines (35 loc) • 1.06 kB
JavaScript
import httpStatus from 'http-status'
import { credentials, baseUrl, signInRoute } from '../data'
import { chaiRequest, expect } from '../setup/chaiHttpHelper'
import { getDbConfigWithInactiveUser } from './helper'
describe('Sign up user', () => {
const request = chaiRequest(baseUrl)
let server
before(done => {
getDbConfigWithInactiveUser()
.then(({ server: srv })=>{
server = srv
})
.then(() => done())
})
describe(`Sign in with invalid password`, () => {
it(`Should return ${httpStatus[httpStatus.UNAUTHORIZED]}`,
done => {
request
.post(signInRoute)
.send({ ...credentials, password: 'no-' + credentials.password })
.end((err, res) => {
const { body } = res
expect(res).to.have.status(httpStatus.UNAUTHORIZED)
expect(body.message)
.to.equal(httpStatus[ httpStatus.UNAUTHORIZED ])
done()
})
}
)
})
after(done => {
server.stop()
done()
})
})