mirror of
https://example.com
synced 2024-11-24 07:46:39 +09:00
Use Promise
This commit is contained in:
parent
a8ade110e6
commit
e7890eb6b9
1 changed files with 6 additions and 7 deletions
13
test/api.ts
13
test/api.ts
|
@ -29,18 +29,17 @@ const async = fn => (done) => {
|
|||
});
|
||||
};
|
||||
|
||||
const request = (endpoint, params, me?) => new Promise<any>((ok, ng) => {
|
||||
const request = async (endpoint, params, me?) => {
|
||||
const auth = me ? {
|
||||
i: me.token
|
||||
} : {};
|
||||
|
||||
chai.request(server)
|
||||
const res = await chai.request(server)
|
||||
.post(endpoint)
|
||||
.send(Object.assign(auth, params))
|
||||
.end((err, res) => {
|
||||
ok(res);
|
||||
});
|
||||
});
|
||||
.send(Object.assign(auth, params));
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
describe('API', () => {
|
||||
// Reset database each test
|
||||
|
|
Loading…
Reference in a new issue