@@ -80,6 +80,34 @@ describe('buttons', function () {
80
80
expect ( btn ) . toHaveClass ( 'active' ) ;
81
81
expect ( $scope . model ) . toEqual ( 2 ) ;
82
82
} ) ;
83
+
84
+ describe ( 'setting buttonConfig' , function ( ) {
85
+ var originalActiveClass , originalToggleEvent ;
86
+
87
+ beforeEach ( inject ( function ( buttonConfig ) {
88
+ originalActiveClass = buttonConfig . activeClass ;
89
+ originalToggleEvent = buttonConfig . toggleEvent ;
90
+ buttonConfig . activeClass = false ;
91
+ buttonConfig . toggleEvent = false ;
92
+ } ) ) ;
93
+
94
+ afterEach ( inject ( function ( buttonConfig ) {
95
+ // return it to the original value
96
+ buttonConfig . activeClass = originalActiveClass ;
97
+ buttonConfig . toggleEvent = originalToggleEvent ;
98
+ } ) ) ;
99
+
100
+ it ( 'should use default config when buttonConfig.activeClass and buttonConfig.toggleEvent is false' , function ( ) {
101
+ $scope . model = false ;
102
+ var btn = compileButton ( '<button ng-model="model" btn-checkbox>click</button>' , $scope ) ;
103
+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
104
+
105
+ $scope . model = true ;
106
+ $scope . $digest ( ) ;
107
+ expect ( btn ) . toHaveClass ( 'active' ) ;
108
+ } ) ;
109
+ } ) ;
110
+
83
111
} ) ;
84
112
85
113
describe ( 'radio' , function ( ) {
@@ -137,6 +165,18 @@ describe('buttons', function () {
137
165
expect ( btns . eq ( 1 ) ) . toHaveClass ( 'active' ) ;
138
166
} ) ;
139
167
168
+ it ( 'should do nothing when click active radio' , function ( ) {
169
+ $scope . model = 1 ;
170
+ var btns = compileButtons ( '<button ng-model="model" btn-radio="1">click1</button><button ng-model="model" btn-radio="2">click2</button>' , $scope ) ;
171
+ expect ( btns . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
172
+ expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
173
+
174
+ btns . eq ( 0 ) . click ( ) ;
175
+ $scope . $digest ( ) ;
176
+ expect ( btns . eq ( 0 ) ) . toHaveClass ( 'active' ) ;
177
+ expect ( btns . eq ( 1 ) ) . not . toHaveClass ( 'active' ) ;
178
+ } ) ;
179
+
140
180
describe ( 'uncheckable' , function ( ) {
141
181
//model -> UI
142
182
it ( 'should set active class based on model' , function ( ) {
0 commit comments