I've got my mock window object and method:
var window = {
open: function (url, target, specs) {
var spec, specKey;
this.href = url;
this.target = target;
// Parse through the spec string to grab the parameters you passed through
var specArray = specs.split(',');
for (specKey in specArray) {
spec = specArray[specKey].split('=');
this[String.trim(spec[0])] = String.trim(spec[1]);
}
}
};
and my test case:
describe('$scope.popup1', function () {
it('should open a popup window when ISIN hyperlink is clicked within grid, passing ISIN object s values to shareDataService', inject(function ($window) {
spyOn($window, 'open').and.callFake(function () {
return true;
});
scope.popup1()
expect(window.open).toHaveBeenCalled();
expect(window.open.href).toEqual("views/Box_Ladder.html");
})
)
})
But I get Expected undefined to equal 'views/Box_Ladder.html'
. I'm not sure how window.open.href is undefined seeing as I declared it above?
Aucun commentaire:
Enregistrer un commentaire