@@ -96,6 +96,22 @@ describe('angular-confirm', function() {
9696 expect ( settings . template ) . not . toBeDefined ( ) ;
9797 } ) ;
9898
99+ it ( "should provide default button class names" , function ( ) {
100+ expect ( $confirmModalDefaults . defaultLabels . okClass ) . toEqual ( 'primary' ) ;
101+ expect ( $confirmModalDefaults . defaultLabels . cancelClass ) . toEqual ( 'default' ) ;
102+ var settings = $confirm ( { } ) ;
103+ var data = settings . resolve . data ( ) ;
104+ expect ( data . okClass ) . toEqual ( 'primary' ) ;
105+ expect ( data . cancelClass ) . toEqual ( 'default' ) ;
106+ } ) ;
107+
108+ it ( "should override default class names" , function ( ) {
109+ var settings = $confirm ( { okClass : "danger" , cancelClass : "warning" } ) ;
110+ var data = settings . resolve . data ( ) ;
111+ expect ( data . okClass ) . toEqual ( 'danger' ) ;
112+ expect ( data . cancelClass ) . toEqual ( 'warning' ) ;
113+ } ) ;
114+
99115 } ) ;
100116
101117 describe ( 'confirm directive' , function ( ) {
@@ -205,6 +221,25 @@ describe('angular-confirm', function() {
205221 } ) ;
206222 } ) ;
207223
224+ describe ( 'with confirmOk and confirmOkClass option' , function ( ) {
225+ beforeEach ( angular . mock . inject ( function ( $compile ) {
226+ $scope . name = 'Joe' ;
227+ element = angular . element ( '<button type="button" ng-click="click()" confirm="Are you sure?" confirm-ok="Okie Dokie, {{name}}!" confirm-ok-class="danger">Delete</button>' ) ;
228+ $compile ( element ) ( $scope ) ;
229+ $scope . $digest ( ) ;
230+ } ) ) ;
231+
232+ it ( "should resolve the confirmTitle to the title property" , function ( ) {
233+ element . triggerHandler ( 'click' ) ;
234+ $timeout . flush ( ) ;
235+ expect ( data . ok ) . toEqual ( 'Okie Dokie, Joe!' ) ;
236+ } ) ;
237+
238+ it ( "should use confirmOkClass to the provided value" , function ( ) {
239+ expect ( data . okClass ) . toEqual ( 'danger' ) ;
240+ } ) ;
241+ } ) ;
242+
208243 describe ( 'with confirmCancel option' , function ( ) {
209244 beforeEach ( angular . mock . inject ( function ( $compile ) {
210245 $scope . name = 'Joe' ;
@@ -220,6 +255,25 @@ describe('angular-confirm', function() {
220255 } ) ;
221256 } ) ;
222257
258+ describe ( 'with confirmCancel and cancelClass option' , function ( ) {
259+ beforeEach ( angular . mock . inject ( function ( $compile ) {
260+ $scope . name = 'Joe' ;
261+ element = angular . element ( '<button type="button" ng-click="click()" confirm="Are you sure?" confirm-cancel="No Way, {{name}}!" confirm-cancel-class="warning">Delete</button>' ) ;
262+ $compile ( element ) ( $scope ) ;
263+ $scope . $digest ( ) ;
264+ } ) ) ;
265+
266+ it ( "should resolve the confirmTitle to the title property" , function ( ) {
267+ element . triggerHandler ( 'click' ) ;
268+ $timeout . flush ( ) ;
269+ expect ( data . cancel ) . toEqual ( 'No Way, Joe!' ) ;
270+ } ) ;
271+
272+ it ( "should use confirmCancelClass to the provided value" , function ( ) {
273+ expect ( data . cancelClass ) . toEqual ( 'warning' ) ;
274+ } ) ;
275+ } ) ;
276+
223277 describe ( 'with confirmSettings option' , function ( ) {
224278 beforeEach ( angular . mock . inject ( function ( $compile ) {
225279 $scope . settings = { name : 'Joe' } ;
@@ -231,7 +285,7 @@ describe('angular-confirm', function() {
231285 it ( "should pass the settings to $confirm" , function ( ) {
232286 element . triggerHandler ( 'click' ) ;
233287 $timeout . flush ( ) ;
234- expect ( $confirm ) . toHaveBeenCalledWith ( { text : "Are you sure?" , okClass : "primary" , cancelClass : "default" } , $scope . settings )
288+ expect ( $confirm ) . toHaveBeenCalledWith ( { text : "Are you sure?" } , $scope . settings )
235289 } ) ;
236290 } ) ;
237291
@@ -245,7 +299,7 @@ describe('angular-confirm', function() {
245299 it ( "should pass the settings to $confirm" , function ( ) {
246300 element . triggerHandler ( 'click' ) ;
247301 $timeout . flush ( ) ;
248- expect ( $confirm ) . toHaveBeenCalledWith ( { text : "Are you sure?" , okClass : "primary" , cancelClass : "default" } , { name : "Joe" } )
302+ expect ( $confirm ) . toHaveBeenCalledWith ( { text : "Are you sure?" } , { name : "Joe" } )
249303 } ) ;
250304 } ) ;
251305
0 commit comments