I have the following problem:
A Code snippet from my controller is:
const account = “abc”, isIDValid = true, loadData = this.loadData, that = this;
let args = {account, isIDValid, loadData, that};
dialog.open(args);
My describe in the test is:
describe("when user click open dialog“, function() {
let account, isIDValid, loadData, that, args;
beforeEach(function() {
account = “abc”;
isIDValid = true;
loadData = function() {};
that = folder1.project.Controller;
args = {account, isIDValid, loadData, that};
});
it("should call dialog with args, function() {
controller.abc(isIDValid);
expect(dialog.open).toHaveBeenCalledWith(args);
});
});
I got the following error in javascript Jasmine test:
Expected spy open to have been called with:
[ Object({ account: 'abc', isIDValid: true, loadData: Function, that: Function }) ]
but actual calls were:
[ Object({ account: 'abc', isIDValid: true, loadData: Function, that: EventProvider folder1.project.Controller }) ].
Do someone know how I can mock the function "loadData" and "this" -> EventProvider ??
2
Answers
Thanks, I tried it but got also an error message:
Try with spyOn function by Jasmine