summaryrefslogtreecommitdiff
path: root/test/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/api.js')
-rw-r--r--test/api.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js
index 87773e7baa..42f91779d5 100644
--- a/test/api.js
+++ b/test/api.js
@@ -733,6 +733,45 @@ describe('API', () => {
});
}));
});
+
+ describe('drive/files/update', () => {
+ it('ドライブのファイルを更新できる', () => new Promise(async (done) => {
+ const me = await insertSakurako();
+ const file = await insertDriveFile({
+ user_id: me._id
+ });
+ const newName = 'いちごパスタ.png';
+ request('/drive/files/update', {
+ file_id: file._id.toString(),
+ name: newName
+ }, me).then(res => {
+ res.should.have.status(200);
+ res.body.should.be.a('object');
+ res.body.should.have.property('name').eql(newName);
+ done();
+ });
+ }));
+
+ it('ファイルが存在しなかったら怒る', () => new Promise(async (done) => {
+ request('/drive/files/update', {
+ file_id: '000000000000000000000000',
+ name: 'いちごパスタ.png'
+ }).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('間違ったIDで怒られる', () => new Promise(async (done) => {
+ request('/drive/files/update', {
+ file_id: 'kyoppie',
+ name: 'いちごパスタ.png'
+ }).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+ });
});
async function insertSakurako(opts) {
@@ -752,3 +791,9 @@ async function insertHimawari(opts) {
password: '$2a$08$OPESxR2RE/ZijjGanNKk6ezSqGFitqsbZqTjWUZPLhORMKxHCbc4O' // ilovesakurako
}, opts));
}
+
+async function insertDriveFile(opts) {
+ return await db.get('drive_files').insert(Object.assign({
+ name: 'strawberry-pasta.png'
+ }, opts));
+}