@@ -152,6 +152,31 @@ describe('checkbox', () => {
152
152
expect ( input . checked ) . toEqual ( true ) ;
153
153
expect ( harness . element . checked ) . toEqual ( true ) ;
154
154
} ) ;
155
+
156
+ it ( 'matches :state(checked) when true' , async ( ) => {
157
+ // Arrange
158
+ const { harness} = await setupTest ( ) ;
159
+
160
+ // Act
161
+ harness . element . checked = true ;
162
+ await env . waitForStability ( ) ;
163
+
164
+ // Assert
165
+ expect ( harness . element . matches ( ':state(checked)' ) )
166
+ . withContext ( "element.matches(':state(checked)')" )
167
+ . toBeTrue ( ) ;
168
+ } ) ;
169
+
170
+ it ( 'does not match :state(checked) when false' , async ( ) => {
171
+ // Arrange
172
+ // Act
173
+ const { harness} = await setupTest ( ) ;
174
+
175
+ // Assert
176
+ expect ( harness . element . matches ( ':state(checked)' ) )
177
+ . withContext ( "element.matches(':state(checked)')" )
178
+ . toBeFalse ( ) ;
179
+ } ) ;
155
180
} ) ;
156
181
157
182
describe ( 'indeterminate' , ( ) => {
@@ -169,6 +194,31 @@ describe('checkbox', () => {
169
194
expect ( input . indeterminate ) . toEqual ( false ) ;
170
195
expect ( input . getAttribute ( 'aria-checked' ) ) . not . toEqual ( 'mixed' ) ;
171
196
} ) ;
197
+
198
+ it ( 'matches :state(indeterminate) when true' , async ( ) => {
199
+ // Arrange
200
+ const { harness} = await setupTest ( ) ;
201
+
202
+ // Act
203
+ harness . element . indeterminate = true ;
204
+ await env . waitForStability ( ) ;
205
+
206
+ // Assert
207
+ expect ( harness . element . matches ( ':state(indeterminate)' ) )
208
+ . withContext ( "element.matches(':state(indeterminate)')" )
209
+ . toBeTrue ( ) ;
210
+ } ) ;
211
+
212
+ it ( 'does not match :state(indeterminate) when false' , async ( ) => {
213
+ // Arrange
214
+ // Act
215
+ const { harness} = await setupTest ( ) ;
216
+
217
+ // Assert
218
+ expect ( harness . element . matches ( ':state(indeterminate)' ) )
219
+ . withContext ( "element.matches(':state(indeterminate)')" )
220
+ . toBeFalse ( ) ;
221
+ } ) ;
172
222
} ) ;
173
223
174
224
describe ( 'disabled' , ( ) => {
@@ -186,13 +236,15 @@ describe('checkbox', () => {
186
236
187
237
describe ( 'form submission' , ( ) => {
188
238
async function setupFormTest ( propsInit : Partial < Checkbox > = { } ) {
189
- return await setupTest ( html ` < form >
190
- < md-test-checkbox
191
- .checked =${ propsInit . checked === true }
192
- .disabled =${ propsInit . disabled === true }
193
- .name=${ propsInit . name ?? '' }
194
- .value=${ propsInit . value ?? '' } > </ md-test-checkbox >
195
- </ form > ` ) ;
239
+ return await setupTest (
240
+ html `< form >
241
+ < md-test-checkbox
242
+ .checked =${ propsInit . checked === true }
243
+ .disabled =${ propsInit . disabled === true }
244
+ .name=${ propsInit . name ?? '' }
245
+ .value=${ propsInit . value ?? '' } > </ md-test-checkbox >
246
+ </ form > ` ,
247
+ ) ;
196
248
}
197
249
198
250
it ( 'does not submit if not checked' , async ( ) => {
0 commit comments