From d574d96885db2b1e14435b819af579315b4b02c4 Mon Sep 17 00:00:00 2001 From: Roberto Tonino Date: Tue, 1 Jun 2021 23:02:09 +0200 Subject: [PATCH] fix(server): login-arl tests [skip ci] --- server/src/routes/api/post/login-arl.spec.ts | 4 ++-- server/src/routes/api/post/login-arl.ts | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/server/src/routes/api/post/login-arl.spec.ts b/server/src/routes/api/post/login-arl.spec.ts index 9dfa079..75d50bd 100644 --- a/server/src/routes/api/post/login-arl.spec.ts +++ b/server/src/routes/api/post/login-arl.spec.ts @@ -28,13 +28,13 @@ describe('login-arl requests', () => { const response = await appSendPost(`/api/login-arl/?arl=${process.env.DEEZER_ARL}`) expect(response.status).toBe(200) - expect(response.body).toBe(true) + expect(response.body.status).toBe(true) }) it('should not login using wrong ARL', async () => { const response = await appSendPost(`/api/login-arl/?arl=abcdef1234`) expect(response.status).toBe(200) - expect(response.body).toBe(false) + expect(response.body.status).toBe(false) }) }) diff --git a/server/src/routes/api/post/login-arl.ts b/server/src/routes/api/post/login-arl.ts index 66417be..89d6016 100644 --- a/server/src/routes/api/post/login-arl.ts +++ b/server/src/routes/api/post/login-arl.ts @@ -24,13 +24,11 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n const dz = sessionDZ[req.session.id] if (!req.query) { - res.status(400).send() - return next() + return res.status(400).send() } if (!req.query.arl) { - res.status(400).send() - return next() + return res.status(400).send() } const loginParams: (string | number)[] = [req.query.arl] @@ -54,12 +52,10 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n const testDz = new Deezer() response = await testDz.login_via_arl(...loginParams) } - console.log(response) const returnValue = { status: response, arl: req.query.arl, user: dz.current_user } - res.status(200).send(returnValue) startQueue(dz) - next() + return res.status(200).send(returnValue) } const apiHandler = { path, handler }