I have a file exporting two functions a and b, where b makes a call to a.
I would like to mock a test that when I call b, it calls a with some parameters, but since the two functions are in the same file, I can't find any way of doing this.
functions.js
export const a = (x) => { a very complicated function };
export const b = (x) => a(x+1);
functions.test.js
import { a, b } from './functions';
describe('b', () => {
test('calling b calls a with x+1', () => {
const fakeA = //mock function a ... don't know how to.
b(1);
expect(fakeA).toHaveBeenCalledWith(2);
});
});