From 733d76fa5af5d6ece7d8e2a4486f007d135df604 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Wed, 3 Aug 2022 15:50:57 +0200 Subject: [PATCH] cleanup --- __tests__/findUserPdl.spec.js | 19 ++++++------------- src/findUserPdl.js | 5 +---- src/verifyUserIdentity.js | 1 - 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/__tests__/findUserPdl.spec.js b/__tests__/findUserPdl.spec.js index 92af03b..f694c91 100644 --- a/__tests__/findUserPdl.spec.js +++ b/__tests__/findUserPdl.spec.js @@ -2,14 +2,15 @@ const { errors } = require('cozy-konnector-libs') const { findUserPdl } = require('../src/findUserPdl') const xml2js = require('xml2js') -var mockParsePdl +var mockParseUserPdl // Function to mock in order to test findUserPdl() jest.mock('../src/parsing', () => ({ - parseUserPdl: (mockParsePdl = jest.fn()), + parseUserPdl: (mockParseUserPdl = jest.fn()), })) // Dependencies +jest.spyOn(xml2js, 'parseStringPromise').mockResolvedValue('response') jest.mock('easy-soap-request', () => jest.fn().mockResolvedValue({ response: { @@ -18,20 +19,14 @@ jest.mock('easy-soap-request', () => }) ) -jest.mock('../src/requests/sge', () => ({ - rechercherPoint: jest.fn().mockResolvedValue('response'), -})) - -jest.spyOn(xml2js, 'parseStringPromise').mockResolvedValue('response') - describe('recherchePoint', () => { it('should throw LOGIN_FAILED for too many responses', async () => { - mockParsePdl.mockImplementationOnce(() => { + mockParseUserPdl.mockImplementationOnce(() => { throw new Error('fail') }) try { - const result = await findUserPdl( + await findUserPdl( 'azertyuiop', 'apiKey', 'login@user.com', @@ -40,16 +35,14 @@ describe('recherchePoint', () => { '69069', '69069' ) - console.log('result: ' + result) expect(true).toBe(false) } catch (error) { - console.log('error in test file ' + error) expect(error).toBe(errors.LOGIN_FAILED) } }) it('should return a correct pdl number', async () => { - mockParsePdl.mockResolvedValue('12345') + mockParseUserPdl.mockResolvedValue('12345') expect( await findUserPdl( 'azertyuiop', diff --git a/src/findUserPdl.js b/src/findUserPdl.js index 3a49017..ba18712 100644 --- a/src/findUserPdl.js +++ b/src/findUserPdl.js @@ -47,10 +47,7 @@ async function findUserPdl( }) try { - console.log(parsedReply) - const pdl = parseUserPdl(parsedReply) - console.log('pdl: ' + pdl) - return pdl + return parseUserPdl(parsedReply) } catch (error) { throw errors.LOGIN_FAILED } diff --git a/src/verifyUserIdentity.js b/src/verifyUserIdentity.js index bd62525..e934c5d 100644 --- a/src/verifyUserIdentity.js +++ b/src/verifyUserIdentity.js @@ -27,7 +27,6 @@ async function verifyUserIdentity( fields.postalCode, inseeCode ) - console.log(pdl) if (fields.pointId != pdl) { log('error', 'PointId does not match') -- GitLab