mardi 3 février 2015

Angular js bootstrap $dialog unit tetsing issue

My angular controller looks like this



$scope.confirmNow = function(message,callback,label){
var modalOpts = {

controller : "MyCtrl",

templateUrl : "html_folder/Modal.html",

"backdrop" : true,

"keyboard" : true,

"dialogFade" : true,

"backdropFade" : true,

"resolve" : {

message : function() {return message;},

callback : function() {return callback},

label : function() {return label;}

}

};
$dialog.dialog(modalOpts).open();
}


$scope.performCallback = function(){
//perform the callback
}

$scope.testFunc = function(){
$scope.confirmNow("msg",$scope.performCallback,"lbl");
}


my unit test looks like this.



describe('Groups for Users Controller', function () {
beforeEach(module('ui.bootstrap.dialog'));
beforeEach(inject(function ($rootScope,$dialog, $controller) {
scope = $rootScope.$new();
 dialog = $dialog;
var modalOpts = {

"resolve" : {

message : function() {return "";},

callback : function() {return scope.performCallback},

label : function() {return "";}

}

};
 

scope.fakeDialog = {

response: null,

dialog: function(modalOpts) {

open:{

return this;

}
 

},

open: function(template, controller) {

return this;

},
 then: function(callBack){

callBack(this.response);

}

};
 

ctrl = $controller('WorkgroupsForUsersCtrl', {

$scope: scope,

$dialog: scope.fakeDialog

});

it('should test …..',function(){
scope.testFunc();
});
});


the error that I get it - Unexpected request: GET html-folder/Modal.html


I am trying to mock the entire mode, so ideally the get request to obtain the model page shouldn't happen/ What am I kissing here??


Aucun commentaire:

Enregistrer un commentaire