summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo⭐️ <Syuilotan@yahoo.co.jp>2017-01-18 02:28:47 +0900
committersyuilo⭐️ <Syuilotan@yahoo.co.jp>2017-01-18 02:28:47 +0900
commitcef7fe72edd284aa001aee7ebdda03e4c8bf9c02 (patch)
tree37f4c0cf23762de67404cd66f10be56d388ae2f7
parentUpdate api.js (diff)
downloadsharkey-cef7fe72edd284aa001aee7ebdda03e4c8bf9c02.tar.gz
sharkey-cef7fe72edd284aa001aee7ebdda03e4c8bf9c02.tar.bz2
sharkey-cef7fe72edd284aa001aee7ebdda03e4c8bf9c02.zip
Update api.js
-rw-r--r--test/api.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js
index 84a4457e15..85f199265b 100644
--- a/test/api.js
+++ b/test/api.js
@@ -214,6 +214,64 @@ describe('API', () => {
});
}));
});
+
+ describe('followings/create', () => {
+ it('フォローできる', () => new Promise(async (done) => {
+ const hima = await insertHimawari();
+ const me = await insertSakurako();
+ request('/followings/create', {
+ user_id: hima._id.toString()
+ }, me).then(res => {
+ res.should.have.status(200);
+ res.body.should.be.a('object');
+ res.body.should.have.property('id').eql(hima._id.toString());
+ done();
+ });
+ }));
+
+ it('既にフォローしている場合は怒る', () => new Promise(async (done) => {
+ const hima = await insertHimawari();
+ const me = await insertSakurako();
+ await db.get('followings').insert({
+ followee_id: hima._id,
+ follower_id: me._id
+ });
+ request('/followings/create', {
+ user_id: hima._id.toString()
+ }, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('存在しないユーザーはフォローできない', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ request('/followings/create', {
+ user_id: 'kyoppie'
+ }, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('自分自身はフォローできない', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ request('/followings/create', {
+ user_id: me._id.toString()
+ }, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('空のパラメータで怒られる', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ request('/followings/create', {}, me).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+ });
});
async function insertSakurako() {