fix(server): login-arl tests [skip ci]

This commit is contained in:
Roberto Tonino 2021-06-01 23:02:09 +02:00
parent a9fe54eb72
commit d574d96885
2 changed files with 5 additions and 9 deletions

View File

@ -28,13 +28,13 @@ describe('login-arl requests', () => {
const response = await appSendPost(`/api/login-arl/?arl=${process.env.DEEZER_ARL}`) const response = await appSendPost(`/api/login-arl/?arl=${process.env.DEEZER_ARL}`)
expect(response.status).toBe(200) expect(response.status).toBe(200)
expect(response.body).toBe(true) expect(response.body.status).toBe(true)
}) })
it('should not login using wrong ARL', async () => { it('should not login using wrong ARL', async () => {
const response = await appSendPost(`/api/login-arl/?arl=abcdef1234`) const response = await appSendPost(`/api/login-arl/?arl=abcdef1234`)
expect(response.status).toBe(200) expect(response.status).toBe(200)
expect(response.body).toBe(false) expect(response.body.status).toBe(false)
}) })
}) })

View File

@ -24,13 +24,11 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n
const dz = sessionDZ[req.session.id] const dz = sessionDZ[req.session.id]
if (!req.query) { if (!req.query) {
res.status(400).send() return res.status(400).send()
return next()
} }
if (!req.query.arl) { if (!req.query.arl) {
res.status(400).send() return res.status(400).send()
return next()
} }
const loginParams: (string | number)[] = [req.query.arl] const loginParams: (string | number)[] = [req.query.arl]
@ -54,12 +52,10 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n
const testDz = new Deezer() const testDz = new Deezer()
response = await testDz.login_via_arl(...loginParams) response = await testDz.login_via_arl(...loginParams)
} }
console.log(response)
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user } const returnValue = { status: response, arl: req.query.arl, user: dz.current_user }
res.status(200).send(returnValue)
startQueue(dz) startQueue(dz)
next() return res.status(200).send(returnValue)
} }
const apiHandler = { path, handler } const apiHandler = { path, handler }