From c70f4568f4820279ed6ebca2b56dbc527963cb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?syuilo=E2=AD=90=EF=B8=8F?= Date: Wed, 18 Jan 2017 00:11:31 +0900 Subject: [PATCH] Update api.js --- test/api.js | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/test/api.js b/test/api.js index f3254e620..84a4457e1 100644 --- a/test/api.js +++ b/test/api.js @@ -165,14 +165,54 @@ describe('API', () => { 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; + res.body.reply_to.should.have.property('text').eql(himaPost.text); done(); }); })); - it('repost', () => { + it('repost', () => 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 = { + repost_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('repost_id').eql(post.repost_id); + res.body.should.have.property('repost'); + res.body.repost.should.have.property('text').eql(himaPost.text); + done(); + }); + })); + + it('引用repost', () => 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: 'さく', + repost_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('repost_id').eql(post.repost_id); + res.body.should.have.property('repost'); + res.body.repost.should.have.property('text').eql(himaPost.text); + done(); + }); + })); }); });