From bd86a7ad48c47d7b5b9566f8d9fc499f83f38564 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Jan 2017 11:37:14 +0900 Subject: [PATCH] test --- test/api.js | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/test/api.js b/test/api.js index 34cdcbc93..ad122cf1a 100644 --- a/test/api.js +++ b/test/api.js @@ -46,12 +46,41 @@ describe('API', () => { let me; - it('create account', done => { - request('/signup', account).then(res => { - res.should.have.status(200); - res.body.should.be.a('object'); - res.body.should.have.property('username').eql(account.username); - done(); + describe('signup', () => { + it('不正なユーザー名でアカウントが作成できない', done => { + request('/signup', { + username: 'sakurako.', + password: account.password + }).then(res => { + res.should.have.status(400); + done(); + }); + }); + + it('空のパスワードでアカウントが作成できない', done => { + request('/signup', { + username: account.username, + password: '' + }).then(res => { + res.should.have.status(400); + done(); + }); + }); + + it('正しくアカウントが作成できる', done => { + request('/signup', account).then(res => { + res.should.have.status(200); + res.body.should.be.a('object'); + res.body.should.have.property('username').eql(account.username); + done(); + }); + }); + + it('同じユーザー名のアカウントは作成できない', done => { + request('/signup', account).then(res => { + res.should.have.status(400); + done(); + }); }); });