Skip to content
Snippets Groups Projects
Commit 3ff0575f authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/donnes-tech-debut-contrat' of...

Merge branch 'feat/donnes-tech-debut-contrat' of https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector into feat/donnes-tech-debut-contrat
parents 841cc6d2 f03088d6
No related branches found
No related tags found
1 merge request!12Feat/donnes tech debut contrat
Pipeline #39832 failed
const { errors } = require('cozy-konnector-libs')
const index = require('../src')
const mockSoapRequest = jest.fn()
jest.mock('easy-soap-request', () => async () => mockSoapRequest())
const responseMock = {
response: {
body: 'mockedBody',
},
}
/** Theses tests are not working
* the function getContractStartDate needs to be in a seperate file
* OR the konnector.start needs to be mocked ?
*/
describe('getContractStartDate', () => {
it('should return void when successfully got contract start date ✅', async () => {
mockSoapRequest.mockResolvedValue(responseMock)
expect.assertions(1)
try {
await index.getContractStartDate()
expect(true).toBeTruthy()
} catch (error) {
expect(true).toBe(false)
}
})
it('should throw VENDOR_DOWN when failing request 🚫', async () => {
mockSoapRequest.mockRejectedValueOnce('error')
try {
await index.getContractStartDate()
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.VENDOR_DOWN)
}
})
it('should throw NOT_EXISTING_DIRECTORY when failing parsing 🚫', async () => {
//mock processStartDate
// processStartDate.mockRejectedValueOnce('error')
try {
await index.getContractStartDate()
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.NOT_EXISTING_DIRECTORY)
}
})
})
......@@ -49,6 +49,7 @@ const endDate = moment()
const endDateString = endDate.format('YYYY-MM-DD')
module.exports = new BaseKonnector(start)
module.exports = { getContractStartDate }
// The start function is run by the BaseKonnector instance only when it got all the account
// information (fields). When you run this connector yourself in "standalone" mode or "dev" mode,
......@@ -172,9 +173,8 @@ async function getContractStartDate(url, apiAuthKey, userLogin, pointId) {
headers: sgeHeaders,
xml: consulterDonneesTechniquesContractuelles(pointId, userLogin),
}).catch(err => {
log('error', 'technicalDataResponse')
log('error', err)
return err
log('error', 'Error while fetching contract start date : ' + err)
throw errors.VENDOR_DOWN
})
xml2js.parseString(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment