From 88664486afbdfb89a45b6de90491b4426dccbd6c 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({