From 8a51b89f0fb5d3734e5c4c6eb5610b14c4633bdd Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 16 Oct 2018 08:27:20 +0900 Subject: [PATCH] Refactor --- test/api.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/api.ts b/test/api.ts index ee90da561..cc7c8c529 100644 --- a/test/api.ts +++ b/test/api.ts @@ -32,18 +32,17 @@ const async = (fn: Function) => (done: Function) => { }); }; -const request = (endpoint: string, params: any, me?: any): Promise => new Promise((ok, ng) => { +const request = async (endpoint: string, params: any, me?: any): Promise => { const auth = me ? { - i: me.account.token + i: me.token } : {}; - assert.request(server) + const res = await assert.request(server) .post(endpoint) - .send(Object.assign(auth, params)) - .end((err, res) => { - ok(res); - }); -}); + .send(Object.assign(auth, params)); + + return res; +}; const signup = async (params?: any) => { const q = Object.assign({