[Test] Add some tests

This commit is contained in:
syuilo 2017-02-13 01:17:59 +09:00
parent 54dc1afc99
commit 30ad071575

View file

@ -784,7 +784,7 @@ describe('API', () => {
});
describe('drive/files/update', () => {
it('ドライブのファイルを更新できる', () => new Promise(async (done) => {
it('ファイルの名前を更新できる', () => new Promise(async (done) => {
const me = await insertSakurako();
const file = await insertDriveFile({
user_id: me._id
@ -801,6 +801,58 @@ describe('API', () => {
});
}));
it('他人のファイルは更新できない', () => new Promise(async (done) => {
const me = await insertSakurako();
const hima = await insertHimawari();
const file = await insertDriveFile({
user_id: hima._id
});
request('/drive/files/update', {
file_id: file._id.toString(),
name: 'いちごパスタ.png'
}, me).then(res => {
res.should.have.status(400);
done();
});
}));
it('ファイルのフォルダを更新できる', () => new Promise(async (done) => {
const me = await insertSakurako();
const file = await insertDriveFile({
user_id: me._id
});
const folder = await insertDriveFolder({
user_id: me._id
});
request('/drive/files/update', {
file_id: file._id.toString(),
folder_id: folder._id.toString()
}, me).then(res => {
res.should.have.status(200);
res.body.should.be.a('object');
res.body.should.have.property('folder_id').eql(folder._id.toString());
done();
});
}));
it('他人のフォルダには入れられない', () => new Promise(async (done) => {
const me = await insertSakurako();
const hima = await insertHimawari();
const file = await insertDriveFile({
user_id: me._id
});
const folder = await insertDriveFolder({
user_id: hima._id
});
request('/drive/files/update', {
file_id: file._id.toString(),
folder_id: folder._id.toString()
}, me).then(res => {
res.should.have.status(400);
done();
});
}));
it('存在しないフォルダで怒られる', () => new Promise(async (done) => {
const me = await insertSakurako();
const file = await insertDriveFile({