From 437283fd951db1eddf093a5433e6fb98b30dcb77 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Jan 2017 16:26:21 +0900 Subject: [PATCH] test --- test/api.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/test/api.js b/test/api.js index 8acda018b..f3254e620 100644 --- a/test/api.js +++ b/test/api.js @@ -147,9 +147,28 @@ describe('API', () => { }); })); - it('reply', () => { + it('reply', () => new Promise(async (done) => { + const hima = await insertHimawari(); + const himaPost = await db.get('posts').insert({ + user_id: hima._id, + text: 'ひま' + }); - }); + const me = await insertSakurako(); + const post = { + text: 'さく', + reply_to_id: himaPost._id.toString() + }; + request('/posts/create', post, me).then(res => { + res.should.have.status(200); + res.body.should.be.a('object'); + res.body.should.have.property('text').eql(post.text); + res.body.should.have.property('reply_to_id').eql(post.reply_to_id); + res.body.should.have.property('reply_to'); + res.body.reply_to.should.have.property('text').eql(himaPost.text; + done(); + }); + })); it('repost', () => { @@ -165,3 +184,12 @@ async function insertSakurako() { password: '$2a$14$wlDw/gDIEE7hHpkJA4yZE.bRUZc.ykHhPfVXPaw2cfOldyParYM76' // HimawariDaisuki06160907 }); } + +async function insertHimawari() { + return await db.get('users').insert({ + token: '!00000000000000000000000000000001', + username: 'himawari', + username_lower: 'himawari', + password: '$2a$14$8kwC/akV/Gzk58vsTDAate2ixGjQRtC1j3c4IQAqZ7QLvawRMQsPO' // ilovesakurako + }); +}