From a52eb07fc8a092c56ccad51945c5e25b671aae85 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 18 May 2018 06:37:25 +0900 Subject: [PATCH] Use Promise --- test/api.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/api.ts b/test/api.ts index 98c4cea84..c62fc9c56 100644 --- a/test/api.ts +++ b/test/api.ts @@ -29,18 +29,17 @@ const async = fn => (done) => { }); }; -const request = (endpoint, params, me?) => new Promise((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