I have a non object function
on getConfig.js
export default function () {
/** do something **/
return {
appConfig: { status: true }
}
}
and under my main file
import getConfig from './getConfig';
export default function() {
const { appConfig } = getConfig();
if(appConfig.status) {
console.log("do the right thing");
else {
console.log("do other things")
}
}
}
How do I mock the getConfig function using sinon stub or mock methods? or is there any better way to set appConfig.status property to make true or false?
I would like to do the following but its not working
import getConfig from './getConfig';
import main from './main';
test('should status to be true', () => {
sinon.stub(getConfig).callsFake(sinon.fake.returns({status:true});
expect(main()).toBe('to do the right thing')
}