Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 021e3b9

Browse files
committed
final build; includes test cases to exercise new setting custom template setting
1 parent 26f0e5b commit 021e3b9

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

angular-confirm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ angular.module('angular-confirm', ['ui.bootstrap.modal'])
8282
ngClick: '&',
8383
confirm: '@',
8484
confirmSettings: "=",
85-
confirmTemplateName: "=",
85+
confirmTemplateName: "@",
8686
confirmTitle: '@',
8787
confirmOk: '@',
8888
confirmCancel: '@'

angular-confirm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/confirmSpec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ describe('angular-confirm', function() {
9696
expect(settings.template).not.toBeDefined();
9797
});
9898

99+
it("should use default template", function(){
100+
var settings = $confirm({}, {});
101+
expect(settings.templateUrl).toEqual($confirmModalDefaults.templateUrl)
102+
});
103+
104+
it("should use override template", function(){
105+
var settings = $confirm({}, {templateUrl: 'something'});
106+
expect(settings.templateUrl).not.toEqual($confirmModalDefaults.templateUrl)
107+
expect(settings.templateUrl).toEqual('something');
108+
});
109+
110+
it("should use custom template if found", function(){
111+
$confirmModalDefaults.additionalTemplates.danger = {templateUrl: "something"}
112+
var settings = $confirm({templateName: 'random'}, {});
113+
expect(settings.templateUrl).toEqual($confirmModalDefaults.templateUrl);
114+
115+
settings = $confirm({templateName: 'danger'}, {});
116+
expect(settings.templateUrl).not.toEqual($confirmModalDefaults.templateUrl);
117+
expect(settings.templateUrl).toEqual('something');
118+
119+
settings = $confirm({templateName: 'danger'}, {templateUrl: 'thiswillbeignored'});
120+
expect(settings.templateUrl).not.toEqual($confirmModalDefaults.templateUrl);
121+
expect(settings.templateUrl).toEqual('something');
122+
})
123+
99124
});
100125

101126
describe('confirm directive', function() {
@@ -249,6 +274,20 @@ describe('angular-confirm', function() {
249274
});
250275
});
251276

277+
describe('with confirmTemplateName option', function() {
278+
beforeEach(angular.mock.inject(function($compile) {
279+
element = angular.element('<button type="button" ng-click="click()" confirm="Are you sure?" confirm-template-name="danger">Delete</button>');
280+
$compile(element)($scope);
281+
$scope.$digest();
282+
}));
283+
284+
it("should use custom template", function() {
285+
element.triggerHandler('click');
286+
$timeout.flush();
287+
expect($confirm).toHaveBeenCalledWith({text: "Are you sure?", templateName: "danger"}, {})
288+
});
289+
});
290+
252291

253292
describe('with checkbox', function() {
254293

0 commit comments

Comments
 (0)