forked from FoundKeyGang/FoundKey
[Test] Fix test
This commit is contained in:
parent
a8318851ad
commit
c1df48517f
1 changed files with 14 additions and 21 deletions
35
test/api.js
35
test/api.js
|
@ -29,21 +29,9 @@ const request = (endpoint, params, me) => new Promise((ok, ng) => {
|
||||||
i: me.token
|
i: me.token
|
||||||
} : {};
|
} : {};
|
||||||
|
|
||||||
let file = null;
|
chai.request(server)
|
||||||
|
.post(endpoint)
|
||||||
if (params._file) {
|
.send(Object.assign(auth, params))
|
||||||
file = params._file;
|
|
||||||
delete params._file;
|
|
||||||
}
|
|
||||||
|
|
||||||
let req = chai.request(server)
|
|
||||||
.post(endpoint);
|
|
||||||
|
|
||||||
if (file) {
|
|
||||||
req = req.attach(file[0], file[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
req.send(Object.assign(auth, params))
|
|
||||||
.end((err, res) => {
|
.end((err, res) => {
|
||||||
ok(res);
|
ok(res);
|
||||||
});
|
});
|
||||||
|
@ -724,12 +712,17 @@ describe('API', () => {
|
||||||
describe('drive/files/create', () => {
|
describe('drive/files/create', () => {
|
||||||
it('ドライブのファイルを作成できる', () => new Promise(async (done) => {
|
it('ドライブのファイルを作成できる', () => new Promise(async (done) => {
|
||||||
const me = await insertSakurako();
|
const me = await insertSakurako();
|
||||||
request('/drive/files/create', {
|
chai.request(server)
|
||||||
_file: ['file', fs.readFileSync(__dirname + '/resources/Lenna.png')]
|
.post('/drive/files/create')
|
||||||
}, me).then(res => {
|
.field('i', me.token)
|
||||||
res.should.have.status(204);
|
.attach('file', fs.readFileSync(__dirname + '/resources/Lenna.png'), 'Lenna.png')
|
||||||
done();
|
.end((err, res) => {
|
||||||
});
|
if (err) console.error(err);
|
||||||
|
res.should.have.status(200);
|
||||||
|
res.body.should.be.a('object');
|
||||||
|
res.body.should.have.property('name').eql('Lenna.png');
|
||||||
|
done();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('ファイル無しで怒られる', () => new Promise(async (done) => {
|
it('ファイル無しで怒られる', () => new Promise(async (done) => {
|
||||||
|
|
Loading…
Reference in a new issue