diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-01-20 17:34:04 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-01-20 17:34:09 +0900 |
| commit | 0c7406f8baa26462e1f89cd51c4ef245c6043639 (patch) | |
| tree | 50d549ccbebe0691bc596ec2cc6f81e34d2700ac /test/api.js | |
| parent | [API] Fix bug (diff) | |
| download | misskey-0c7406f8baa26462e1f89cd51c4ef245c6043639.tar.gz misskey-0c7406f8baa26462e1f89cd51c4ef245c6043639.tar.bz2 misskey-0c7406f8baa26462e1f89cd51c4ef245c6043639.zip | |
[Test] Add some tests
Diffstat (limited to 'test/api.js')
| -rw-r--r-- | test/api.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js index e34edd5af7..3f75130dc0 100644 --- a/test/api.js +++ b/test/api.js @@ -341,6 +341,70 @@ describe('API', () => { })); }); + describe('posts/likes/create', () => { + it('いいねできる', () => new Promise(async (done) => { + const hima = await insertHimawari(); + const himaPost = await db.get('posts').insert({ + user_id: hima._id, + text: 'ひま' + }); + + const me = await insertSakurako(); + request('/posts/likes/create', { + post_id: himaPost._id.toString() + }, me).then(res => { + res.should.have.status(200); + done(); + }); + })); + + it('自分の投稿にはいいねできない', () => new Promise(async (done) => { + const me = await insertSakurako(); + const myPost = await db.get('posts').insert({ + user_id: me._id, + text: 'お腹ペコい' + }); + + request('/posts/likes/create', { + post_id: myPost._id.toString() + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('二重にいいねできない', () => new Promise(async (done) => { + const hima = await insertHimawari(); + const himaPost = await db.get('posts').insert({ + user_id: hima._id, + text: 'ひま' + }); + + await db.get('likes').insert({ + user_id: me._id, + post_id: himaPost._id + }); + + const me = await insertSakurako(); + request('/posts/likes/create', { + post_id: himaPost._id.toString() + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('存在しない投稿にはいいねできない', () => new Promise(async (done) => { + const me = await insertSakurako(); + request('/posts/likes/create', { + post_id: '000000000000000000000000' + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + }); + describe('following/create', () => { it('フォローできる', () => new Promise(async (done) => { const hima = await insertHimawari(); |