I am very new to unit testing. I have one angular service which uses ngDialouge - this is 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 is the one I want to test -i.e. alert and updation of scope ****
//alert the message and update some related scope variables login
}
if (res.value === "2")
{
//**Below is the one I want to test -i.e. alert and updation of scope
//alert the message and update some related scope variables login
}
.....
return response()
Now I want to unit test messages and test whether scope.msg got updated depending on the dialogue box selection (Yes gives different msg and No gives different msg). If I want to test those messages I need to mock ngDialog and also their choices (Yes/No), but I am confused between how to do it exactly. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire