From 97eae15b2d959254294d3cba347160f72e621b8c Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 13 Feb 2017 01:10:26 +0900 Subject: [PATCH] [Test] Add some tests --- test/api.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/api.js b/test/api.js index 8a3fef416..d0f2aecd7 100644 --- a/test/api.js +++ b/test/api.js @@ -235,6 +235,40 @@ describe('API', () => { }); })); + it('他人のファイルは添付できない', () => new Promise(async (done) => { + const me = await insertSakurako(); + const hima = await insertHimawari(); + const file = await insertDriveFile({ + user_id: hima._id + }); + request('/posts/create', { + media_ids: [file._id.toString()] + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('存在しないファイルは添付できない', () => new Promise(async (done) => { + const me = await insertSakurako(); + request('/posts/create', { + media_ids: ['000000000000000000000000'] + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('不正なファイルIDで怒られる', () => new Promise(async (done) => { + const me = await insertSakurako(); + request('/posts/create', { + media_ids: ['kyoppie'] + }, 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({