@@ -8,7 +8,7 @@ import {MatCheckboxModule as MatMdcCheckboxModule} from '../index';
8
8
import { MatCheckboxHarness } from './checkbox-harness' ;
9
9
import { MatCheckboxHarness as MatMdcCheckboxHarness } from './mdc-checkbox-harness' ;
10
10
11
- let fixture : ComponentFixture < unknown > ;
11
+ let fixture : ComponentFixture < CheckboxHarnessTest > ;
12
12
let loader : HarnessLoader ;
13
13
let checkboxHarness : typeof MatCheckboxHarness ;
14
14
@@ -141,6 +141,7 @@ function runTests() {
141
141
} ) ;
142
142
143
143
it ( 'should toggle checkbox' , async ( ) => {
144
+ fixture . componentInstance . disabled = false ;
144
145
const checkboxes = await loader . getAllHarnesses ( checkboxHarness ) ;
145
146
await checkboxes [ 0 ] . toggle ( ) ;
146
147
await checkboxes [ 1 ] . toggle ( ) ;
@@ -149,6 +150,7 @@ function runTests() {
149
150
} ) ;
150
151
151
152
it ( 'should check checkbox' , async ( ) => {
153
+ fixture . componentInstance . disabled = false ;
152
154
const checkboxes = await loader . getAllHarnesses ( checkboxHarness ) ;
153
155
await checkboxes [ 0 ] . check ( ) ;
154
156
await checkboxes [ 1 ] . check ( ) ;
@@ -157,12 +159,20 @@ function runTests() {
157
159
} ) ;
158
160
159
161
it ( 'should uncheck checkbox' , async ( ) => {
162
+ fixture . componentInstance . disabled = false ;
160
163
const checkboxes = await loader . getAllHarnesses ( checkboxHarness ) ;
161
164
await checkboxes [ 0 ] . uncheck ( ) ;
162
165
await checkboxes [ 1 ] . uncheck ( ) ;
163
166
expect ( await checkboxes [ 0 ] . isChecked ( ) ) . toBe ( false ) ;
164
167
expect ( await checkboxes [ 1 ] . isChecked ( ) ) . toBe ( false ) ;
165
168
} ) ;
169
+
170
+ it ( 'should not toggle disabled checkbox' , async ( ) => {
171
+ const checkbox = await loader . getHarness ( checkboxHarness . with ( { label : 'Second' } ) ) ;
172
+ expect ( await checkbox . isChecked ( ) ) . toBe ( false ) ;
173
+ await checkbox . toggle ( ) ;
174
+ expect ( await checkbox . isChecked ( ) ) . toBe ( false ) ;
175
+ } ) ;
166
176
}
167
177
168
178
function getActiveElementTagName ( ) {
@@ -179,13 +189,14 @@ function getActiveElementTagName() {
179
189
aria-label="First checkbox">
180
190
First
181
191
</mat-checkbox>
182
- <mat-checkbox indeterminate="true" disabled="true " aria-labelledby="second-label">
192
+ <mat-checkbox indeterminate="true" [ disabled]="disabled " aria-labelledby="second-label">
183
193
Second
184
194
</mat-checkbox>
185
195
<span id="second-label">Second checkbox</span>
186
196
`
187
197
} )
188
198
class CheckboxHarnessTest {
189
199
ctrl = new FormControl ( true ) ;
200
+ disabled = true ;
190
201
}
191
202
0 commit comments