Unit testing
Modal service for AngularJS - supports creating popups and modals via a service.
Brought to you by:
evanfcrane
Originally created by: jlambert121
Thank you for this great addition to angular, I love the flexibility and ease of use.
I am trying to write unit tests for a controller I'm using in a modal and cannot figure out how to inject the close provider into my tests since it looks like there's some angular magic going on. Any tips to help?
it('should implement close()', function () {
inject(function ($controller, $rootScope) {
var scope;
scope = $rootScope.$new();
$controller('TemplateController', { $scope: scope } );
expect(angular.isFunction(scope.close)).toBeTruthy();
});
}); // should implement close()
The controller is as simple as:
TimelineControllers.controller('TemplateController', ['$scope', 'close', function($scope, close) {
$scope.close = function () {
close('i was closed');
};
}]);
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Ticket changed by: jlambert121
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: dwmkerr
Hi @jlambert121 sorry for the late reply, let me raise an issue to document unit testing with Angular Modal Service, hopefully this should be useful!\
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: sajadghobadi
first define below line
after write mentioned lines in before function you donot see this error
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: PratibhaP
I also have the same issue, the only difference is that using custom modal, so, I don't need a $element.
Error: [$injector:unpr] Unknown provider: closeProvider <- close <- changePasswordController
while running unit testing. Can you help please me.
Thank you in advance.