@@ -81,6 +81,23 @@ describe('buttons', function () {
81
81
expect ( $scope . model ) . toEqual ( 2 ) ;
82
82
} ) ;
83
83
84
+ it ( 'should not toggle when disabled - issue 4013' , function ( ) {
85
+ $scope . model = 1 ;
86
+ $scope . falseVal = 0 ;
87
+ var btn = compileButton ( '<button disabled ng-model="model" btn-checkbox btn-checkbox-true="falseVal">click</button>' , $scope ) ;
88
+
89
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
90
+ expect ( $scope . model ) . toEqual ( 1 ) ;
91
+
92
+ btn . click ( ) ;
93
+
94
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
95
+
96
+ $scope . $digest ( ) ;
97
+
98
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
99
+ } ) ;
100
+
84
101
describe ( 'setting buttonConfig' , function ( ) {
85
102
var originalActiveClass , originalToggleEvent ;
86
103
@@ -177,6 +194,24 @@ describe('buttons', function () {
177
194
expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
178
195
} ) ;
179
196
197
+ it ( 'should not toggle when disabled - issue 4013' , function ( ) {
198
+ $scope . model = 1 ;
199
+ var btns = compileButtons ( '<button ng-model="model" btn-radio="1">click1</button><button disabled ng-model="model" btn-radio="2">click2</button>' , $scope ) ;
200
+
201
+ expect ( btns . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
202
+ expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
203
+
204
+ btns . eq ( 1 ) . click ( ) ;
205
+
206
+ expect ( btns . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
207
+ expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
208
+
209
+ $scope . $digest ( ) ;
210
+
211
+ expect ( btns . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
212
+ expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
213
+ } ) ;
214
+
180
215
describe ( 'uncheckable' , function ( ) {
181
216
//model -> UI
182
217
it ( 'should set active class based on model' , function ( ) {
0 commit comments