|
@@ -6,6 +6,7 @@ let server = require('../server')
|
|
|
let should = chai.should()
|
|
|
|
|
|
let User = require('../models').User
|
|
|
+const Errors = require('../lib/errors.js');
|
|
|
|
|
|
chai.use(chaiHttp)
|
|
|
|
|
@@ -37,6 +38,38 @@ describe('User', () => {
|
|
|
res.body.should.have.property('username', 'test')
|
|
|
res.body.should.have.property('hash')
|
|
|
|
|
|
+ done()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ it('should throw an error if no username', (done) => {
|
|
|
+ chai.request(server)
|
|
|
+ .post('/api/v1/user')
|
|
|
+ .set('content-type', 'application/x-www-form-urlencoded')
|
|
|
+ .send({
|
|
|
+ password: 'pass'
|
|
|
+ })
|
|
|
+ .end((err, res) => {
|
|
|
+ res.should.have.status(500)
|
|
|
+ res.should.be.json
|
|
|
+ res.body.should.have.property('error')
|
|
|
+ res.body.error.should.deep.equal()
|
|
|
+
|
|
|
+ done()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ it('should throw an error if no pass', (done) => {
|
|
|
+ chai.request(server)
|
|
|
+ .post('/api/v1/user')
|
|
|
+ .set('content-type', 'application/x-www-form-urlencoded')
|
|
|
+ .send({
|
|
|
+ username: 'test1'
|
|
|
+ })
|
|
|
+ .end((err, res) => {
|
|
|
+ res.should.have.status(200)
|
|
|
+ res.should.be.json
|
|
|
+ res.body.should.have.property('username', 'test')
|
|
|
+ res.body.should.have.property('hash')
|
|
|
+
|
|
|
done()
|
|
|
})
|
|
|
})
|