I'm quite new in the NodeJS world. I have a question : I'm trying to put a unit test with Jest in order to test this 'Service' with the 2 functions as below in the quotationService.js file :
export default ({ quotationRepository }) => {
const getQuotations = (runComputationData) =>
Promise.resolve()
.then(async () => {
const promise = quotationRepository.runComputation(runComputationData);
const quotationsResult = await Promise.all([promise]);
const quotations = quotationsResult[0];
return quotations;
})
.catch((error) => {
throw error;
});
const sum = (a, b) => a + b;
return {
getQuotations,
sum
};
};
And in my test file, i have :
import quotationServices from '../../../../../src/domain/financing/quotation/quotationServices.js';
describe('sum module', () => {
test('adds 1 + 2 to equal 3', () => {
expect(quotationServices.sum(1, 2)).toBe(3);
});
});
The point is that i don't really know the syntaxe to mock the sum function for a unit test, i have this result :
Does someone have an idea please ? Thanks
