diff --git a/__tests__/verifyUserIdentity.spec.js b/__tests__/verifyUserIdentity.spec.js index cf8aee42062880db734c389b783f7313c9e4951b..74950d0eb1d3b3a8145a97c050f1630ce9716579 100644 --- a/__tests__/verifyUserIdentity.spec.js +++ b/__tests__/verifyUserIdentity.spec.js @@ -1,7 +1,9 @@ const { errors } = require('cozy-konnector-libs') const { verifyUserIdentity } = require('../src/index') -const insee = require('./requests/insee') +jest.mock('../src/requests/insee', () => ({ + getInseeCode: jest.fn().mockResolvedValueOnce(69), +})) describe('verifyUserIdentity', () => { // mock insee code // mock find User Pdl @@ -9,21 +11,22 @@ describe('verifyUserIdentity', () => { // const mockFindUserPdl = jest.fn() it('should throw LOGIN_FAILED when pdl give and recieved are not matching', async () => { - jest.spyOn(insee, 'getInseeCode').mockResolvedValueOnce(696969) + const result = await verifyUserIdentity( + { + name: 'John', + address: '1 street', + pointId: 987654321, + postalCode: '69069', + }, + 'baseUrl', + 'apiKey', + 'login@user.com' + ) + // jest + // .mock(verifyUserIdentity(), 'getInseeCode') + // .mockResolvedValueOnce(696969) // jest.spyOn(verifyUserIdentity, 'findUserPdl').mockResolvedValueOnce(696969) - expect( - verifyUserIdentity( - { - name: 'John', - address: '1 street', - pointId: 987654321, - postalCode: '69069', - }, - 'baseUrl', - 'apiKey', - 'login@user.com' - ) - ).toBe(errors.LOGIN_FAILED) + expect(result).toBe(errors.LOGIN_FAILED) }) })