소스 검색

Add tests for new get user route

sbkwgh 8 년 전
부모
커밋
cd8b167d65
1개의 변경된 파일27개의 추가작업 그리고 0개의 파일을 삭제
  1. 27 0
      test/user.js

+ 27 - 0
test/user.js

@@ -267,6 +267,33 @@ describe('User', () => {
 
 	})
 
+	describe('/:username GET user', () => {
+		it('should return the user', async () => {
+			let res = await chai.request(server)
+				.get('/api/v1/user/username')
+
+			res.should.have.status(200)
+			res.should.be.json
+			res.body.should.have.property('username', 'username')
+			res.body.should.have.property('color')
+			res.body.should.not.have.property('hash')
+		})
+
+		it('should return an error if username invalid', async () => {
+			try {
+				let res = await chai.request(server)
+					.get('/api/v1/user/not_a_user')
+
+				res.should.have.status(400)
+				res.body.errors.should.contain.something.that.deep.equals(Errors.accountDoesNotExist)
+			} catch(res) {
+				let body = JSON.parse(res.response.text)
+				res.should.have.status(400)
+				body.errors.should.contain.something.that.deep.equals(Errors.accountDoesNotExist)
+			}
+		})
+	})
+
 	describe('/:username/login POST user', () => {
 		let agent = chai.request.agent(server)