I am using jest to do testing for my newly built app. However, i am finding difficulties to test certain components when they are in a function. Sounds confusing, but it goes like this:
export default function Calculation(){
...
const sum = (a, b) => {
return a + b;
}
const divide= (a, b) => {
return a / b;
}
...
When i want to test the sum function i get expected 0 arguments, but got 2
import Calculation from "./Calculation";
test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
});
Is there a way to import sum and divide to do the testing without needing to make a separate functions file to do this?