[Test] Add some tests
This commit is contained in:
parent
d0f8634865
commit
a6ce54ec18
1 changed files with 45 additions and 0 deletions
45
test/api.js
45
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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue