i new unit testing. have 1 angular service uses ngdialouge - has 2 radio buttons yes/no.
angular.module('jasminkarmapoc1app') .factory('fatelayingservice', fatelayingservice); ..... var response = {} response.avoidpayment = function (playerdetails){ .... var prom = ngdialog.open( { template: 'scripts/decisionbox/fate-decision- modal-window.html', controller: 'decisionboxcontroller' } ); prom.closepromise.then(function (res) { if (res.value === "1") { //***below 1 want test -i.e. alert , updation of scope **** //alert message , update related scope variables login } if (res.value === "2") { //**below 1 want test -i.e. alert , updation of scope //alert message , update related scope variables login } ..... return response()
now want unit test messages , test whether scope.msg got updated depending on dialogue box selection (yes gives different msg , no gives different msg). if want test messages need mock ngdialog , choices (yes/no), confused between how exactly. appreciated.
i'm not sure if want use open or openconfirm. here's open
ngdialog = jasmine.createspyobj('ngdialog', ['open']); ngdialog.open.and.returnvalue({ closepromise : { then : function(callback) { callback({value: 1}); } } }); /* test res.value = 1*/ response.avoidpayment();
Comments
Post a Comment