sbkwgh 7 yıl önce
ebeveyn
işleme
8bec7b0d6a
2 değiştirilmiş dosya ile 5 ekleme ve 41 silme
  1. 4 1
      models/user.js
  2. 1 40
      test/user.js

+ 4 - 1
models/user.js

@@ -158,7 +158,10 @@ module.exports = (sequelize, DataTypes) => {
 							throw Errors.invalidToken
 						}
 					} else {
-						throw Errors.missingParameter('token')
+						throw Errors.sequelizeValidation(sequelize, {
+							error: 'Missing token',
+							path: 'token'
+						})
 					}
 	
 				} else {

+ 1 - 40
test/user.js

@@ -79,7 +79,7 @@ describe('User', () => {
 					res.should.have.status(400)
 					res.should.be.json
 					res.body.should.have.property('errors')
-					res.body.errors.should.include.something.that.deep.equals(Errors.missingParameter('token'))
+					res.body.errors.should.include.something.that.has.property('message', 'Missing token')
 
 					done()
 				})
@@ -451,45 +451,6 @@ describe('User', () => {
 		})
 	})
 
-	describe('/?admin', () => {
-		let admin1 = chai.request.agent(server)
-		before(done => {
- 			admin1
-				.post('/api/v1/user/adminaccount/login')
-				.set('content-type', 'application/json')
-				.send({
-					password: 'password'
-				})
-				.then(_ =>  {
-					done()
-				})
-				.catch(done)
-		})
-
-		it('should return an array of admins', async () => {
-			let res = await admin1.get('/api/v1/user?admin=true')
-
-			res.should.be.json
-			res.should.have.status(200)
-			res.body.should.contain.something.with.property('username', 'adminaccount')
-			res.body.should.contain.something.with.property('username', 'adminaccount1')
-			res.body.should.not.contain.something.with.property('hash')
-			res.body.should.have.property('length', 2)
-		})
-
-		it('should return an error if not admin', done => {
-			chai.request(server)
-				.get('/api/v1/user?admin=true')
-				.end((err, res) => {
-					res.should.have.status(401)
-					res.body.should.have.property('errors')
-					res.body.errors.should.contain.something.that.deep.equals(Errors.requestNotAuthorized)
-
-					done()
-				})
-		})
-	})
-
 	describe('/:username/login POST user', () => {
 		let agent = chai.request.agent(server)