Newer
Older
const { errors } = require('cozy-konnector-libs')
const { findUserPdl } = require('../src/findUserPdl')
jest.spyOn(xml2js, 'parseStringPromise').mockResolvedValue('response')
jest.mock('easy-soap-request', () => (mockSoapRequest = jest.fn()))
const responseMock = {
response: {
body: 'mockedBody',
},
}
describe('recherchePoint', () => {
it('should throw LOGIN_FAILED for too many responses', async () => {
'azertyuiop',
'apiKey',
'login@user.com',
'John',
'1 street',
'69069',
'69069'
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
}
})
it('should throw LOGIN_FAIL if soapRequest fails', async () => {
mockSoapRequest.mockRejectedValueOnce('reject')
try {
await findUserPdl(
'azertyuiop',
'apiKey',
'login@user.com',
'John',
'1 street',
'69069',
'69069'
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
}
})
it('should return a correct pdl number', async () => {