Skip to content
Snippets Groups Projects
verifyUserIdentity.spec.js 937 B
Newer Older
  • Learn to ignore specific revisions
  • Bastien DUMONT's avatar
    Bastien DUMONT committed
    const { errors } = require('cozy-konnector-libs')
    const { verifyUserIdentity } = require('../src/index')
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    jest.mock('../src/requests/insee', () => ({
      getInseeCode: jest.fn().mockResolvedValueOnce(69),
    }))
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    describe('verifyUserIdentity', () => {
      // mock insee code
      // mock find User Pdl
      // const mockGetInseeCode = jest.fn()
      // const mockFindUserPdl = jest.fn()
    
      it('should throw LOGIN_FAILED when pdl give and recieved are not matching', async () => {
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        const result = await verifyUserIdentity(
          {
            name: 'John',
            address: '1 street',
            pointId: 987654321,
            postalCode: '69069',
          },
          'baseUrl',
          'apiKey',
          'login@user.com'
        )
        // jest
        //   .mock(verifyUserIdentity(), 'getInseeCode')
        //   .mockResolvedValueOnce(696969)
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        // jest.spyOn(verifyUserIdentity, 'findUserPdl').mockResolvedValueOnce(696969)
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        expect(result).toBe(errors.LOGIN_FAILED)
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      })
    })