Below the controller am trying to test
(function() {
'use strict';
angular
.module('bsp.account.modals')
.controller('ChangePasswordModal', ChangePasswordModal);
function ChangePasswordModal($modalInstance, accountModalsService) {
var vm = this;
vm.title = 'ChangePasswordModal';
vm.pwObj = {
currentPassword: '',
newPassword1: '',
newPassword2: ''
};
vm.pwObjError = {};
vm.fields = [{
label: 'Current Password',
id: 'currentPassword'
}, {
label: 'New Password',
id: 'newPassword1'
}, {
label: 'Confirm Password',
id: 'newPassword2'
}];
vm.submitPasswordChange = function() {
accountModalsService.submitPasswordChange(vm.pwObj, vm.pwObjError,$modalInstance);
};
vm.cancel = cancel;
function cancel() {
$modalInstance.dismiss('cancel');
}
}
})();
Want to test the method vm.submitPasswordchange = function(){}; and vm.cancel(){$modalInstance.dismiss('cancel');}
my test case written in Jasmin:
` describe("change-Password-Controller", function() { var controller = null, scope, testmodalInstance, testaccountModalsService;
beforeEach(module('bsp.account.modals'));
//dummy test
it("is a dummy test", inject(function() {
expect(true).toBeTruthy();
}));
beforeEach(inject(function($rootScope, $controller) {
scope = $rootScope.$new();
testaccountModalsService = {
submitPasswordChange: function() {}
};
controller = $controller("ChangePasswordModal", {
$scope: scope,
$modalInstance: testmodalInstance,
accountModalsService: testaccountModalsService
});
scope.vm = controller;
}));
describe("title", function() {
it("title should be -ChangePasswordModal", function() {
expect(controller.title).toBe("ChangePasswordModal");
});
});
describe("submitPasswordChange", function() {
it("should check Passwordchange", function() {
});
});
});
It would be great to get your valuable suggestions .please ignore my ignorance being new to this framework
Aucun commentaire:
Enregistrer un commentaire