From 988de1dd1860d604cf7cd8c16f766ed3eee13180 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Jan 2017 11:28:50 +0900 Subject: [PATCH] test --- test/api.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/test/api.js b/test/api.js index 8ae4fba743..34cdcbc936 100644 --- a/test/api.js +++ b/test/api.js @@ -55,11 +55,24 @@ describe('API', () => { }); }); - it('signin', done => { - request('/signin', account).then(res => { - res.should.have.status(204); - me = res.header['set-cookie'][0].match(/i=(!\w+)/)[1]; - done(); + describe('signin', () => { + it('間違ったパスワードでサインインできない', done => { + request('/signin', { + username: account.username, + password: account.password + '.' + }).then(res => { + res.should.have.status(400); + res.text.should.be.equal('incorrect password'); + done(); + }); + }); + + it('正しい情報で正しくサインインできる', done => { + request('/signin', account).then(res => { + res.should.have.status(204); + me = res.header['set-cookie'][0].match(/i=(!\w+)/)[1]; + done(); + }); }); }); @@ -75,6 +88,18 @@ describe('API', () => { done(); }); }); + + it('update my location', done => { + const myLocation = '七森中'; + request('/i/update', { + location: myLocation + }, me).then(res => { + res.should.have.status(200); + res.body.should.be.a('object'); + res.body.should.have.property('location').eql(myLocation); + done(); + }); + }); }); describe('posts/create', () => {