"I'm trying to cover my default function through to jasmine. But facing issue with dependency files where jasmine is unable to took reference of those dependency. Getting 1 error utils is not defined and 2 error Expected undefined to be function".
"I tried to create mock data for utils is not defined and second i didn't try. But i was able to reproduce second error after comment utils line and that is for x storage."
const default = (newu) => {
newu.isPay = utils.isPayUser(b$.portal.loggedInUserRole);
xStorage.getItem('Id').then(value => {
newu.successResponse.bId = value;
newu.bId = newu.successResponse.bId.replace(/-/g, "");
newu.bId = newu.bId.slice(0, -10);
});
}
describe('default', () => {
it('default is defined', () => {
let yesValue = true;
let utils = {
isPayUser:(yesValue)=>{}
}
expect(default(ctrl)).toBeFunction();
});
});
"How i can cover functions with third party dependencies. Do we write some mock data and if yes what would be the way to write it. Utils and xstorage is a function and coming from dependency files which i already imported in my js file. This method will returns me true “utils.isPayUser(b$.portal.loggedInUserRole);” and xstorage return me get item. Xstorage is a method where we can store a value and whenever or wherever can access to get that value as like as sessionstorage."