From e7890eb6b94870231af0e9654c96845bfb0c1f42 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 98c4cea84e..c62fc9c56a 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