@@ -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