From cd5e49c9c2c9b2ecbbd31fd4090f5f2c3d8d088f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 12 Feb 2017 11:18:36 +0900 Subject: [PATCH] [Test] Add some drive tests --- test/api.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/api.js b/test/api.js index 20d97e291..678d4ff5c 100644 --- a/test/api.js +++ b/test/api.js @@ -752,6 +752,34 @@ describe('API', () => { }); })); + it('存在しないフォルダで怒られる', () => new Promise(async (done) => { + const me = await insertSakurako(); + const file = await insertDriveFile({ + user_id: me._id + }); + request('/drive/files/update', { + file_id: file._id.toString(), + folder_id: '000000000000000000000000' + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('不正なフォルダIDで怒られる', () => new Promise(async (done) => { + const me = await insertSakurako(); + const file = await insertDriveFile({ + user_id: me._id + }); + request('/drive/files/update', { + file_id: file._id.toString(), + folder_id: 'kyoppie' + }, me).then(res => { + res.should.have.status(400); + done(); + }); + })); + it('ファイルが存在しなかったら怒る', () => new Promise(async (done) => { const me = await insertSakurako(); request('/drive/files/update', { @@ -774,6 +802,20 @@ describe('API', () => { }); })); }); + + describe('drive/folders/create', () => { + it('ドライブのフォルダを作成できる', () => new Promise(async (done) => { + const me = await insertSakurako(); + request('/drive/folders/create', { + name: 'my folder' + }, me).then(res => { + res.should.have.status(200); + res.body.should.be.a('object'); + res.body.should.have.property('name').eql('my folder'); + done(); + }); + })); + }); }); async function insertSakurako(opts) {