From af08b2d8d186ad6faedeec224ac02627ce08706c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 18 Jan 2017 05:44:06 +0900 Subject: [PATCH] [Test] Add some tests --- test/api.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test/api.js b/test/api.js index 2773540ba..23116f687 100644 --- a/test/api.js +++ b/test/api.js @@ -134,7 +134,7 @@ describe('API', () => { })); describe('posts/create', () => { - it('simple', () => new Promise(async (done) => { + it('投稿できる', () => new Promise(async (done) => { const me = await insertSakurako(); const post = { text: 'ひまわりー' @@ -147,7 +147,7 @@ describe('API', () => { }); })); - it('reply', () => new Promise(async (done) => { + it('返信できる', () => new Promise(async (done) => { const hima = await insertHimawari(); const himaPost = await db.get('posts').insert({ user_id: hima._id, @@ -170,7 +170,7 @@ describe('API', () => { }); })); - it('repost', () => new Promise(async (done) => { + it('repostできる', () => new Promise(async (done) => { const hima = await insertHimawari(); const himaPost = await db.get('posts').insert({ user_id: hima._id, @@ -191,7 +191,7 @@ describe('API', () => { }); })); - it('引用repost', () => new Promise(async (done) => { + it('引用repostできる', () => new Promise(async (done) => { const hima = await insertHimawari(); const himaPost = await db.get('posts').insert({ user_id: hima._id, @@ -214,6 +214,28 @@ describe('API', () => { }); })); + it('文字数ぎりぎりで怒られない', () => new Promise(async (done) => { + const me = await insertSakurako(); + const post = { + text: '!'.repeat(500) + }; + request('/posts/create', post, me).then(res => { + res.should.have.status(200); + done(); + }); + })); + + it('文字数オーバーで怒られる', () => new Promise(async (done) => { + const me = await insertSakurako(); + const post = { + text: '!'.repeat(501) + }; + request('/posts/create', post, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + it('存在しないリプライ先で怒られる', () => new Promise(async (done) => { const me = await insertSakurako(); const post = {