File tree Expand file tree Collapse file tree 7 files changed +41
-4
lines changed
tools/public_api_guard/material Expand file tree Collapse file tree 7 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,7 @@ import {BaseHarnessFilters} from '@angular/cdk/testing';
13
13
* @deprecated Use `SelectHarnessFilters` from `@angular/material/select/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
14
14
* @breaking -change 17.0.0
15
15
*/
16
- export interface LegacySelectHarnessFilters extends BaseHarnessFilters { }
16
+ export interface LegacySelectHarnessFilters extends BaseHarnessFilters {
17
+ /** Only find instances which match the given disabled state. */
18
+ disabled ?: boolean ;
19
+ }
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ export class MatLegacySelectHarness extends _MatSelectHarnessBase<
41
41
* @return a `HarnessPredicate` configured with the given options.
42
42
*/
43
43
static with ( options : LegacySelectHarnessFilters = { } ) : HarnessPredicate < MatLegacySelectHarness > {
44
- return new HarnessPredicate ( MatLegacySelectHarness , options ) ;
44
+ return new HarnessPredicate ( MatLegacySelectHarness , options ) . addOption (
45
+ 'disabled' ,
46
+ options . disabled ,
47
+ async ( harness , disabled ) => {
48
+ return ( await harness . isDisabled ( ) ) === disabled ;
49
+ } ,
50
+ ) ;
45
51
}
46
52
}
Original file line number Diff line number Diff line change 9
9
import { BaseHarnessFilters } from '@angular/cdk/testing' ;
10
10
11
11
/** A set of criteria that can be used to filter a list of `MatSelectHarness` instances. */
12
- export interface SelectHarnessFilters extends BaseHarnessFilters { }
12
+ export interface SelectHarnessFilters extends BaseHarnessFilters {
13
+ /** Only find instances which match the given disabled state. */
14
+ disabled ?: boolean ;
15
+ }
Original file line number Diff line number Diff line change @@ -182,6 +182,12 @@ export class MatSelectHarness extends _MatSelectHarnessBase<
182
182
this : ComponentHarnessConstructor < T > ,
183
183
options : SelectHarnessFilters = { } ,
184
184
) : HarnessPredicate < T > {
185
- return new HarnessPredicate ( this , options ) ;
185
+ return new HarnessPredicate ( this , options ) . addOption (
186
+ 'disabled' ,
187
+ options . disabled ,
188
+ async ( harness , disabled ) => {
189
+ return ( await harness . isDisabled ( ) ) === disabled ;
190
+ } ,
191
+ ) ;
186
192
}
187
193
}
Original file line number Diff line number Diff line change @@ -44,6 +44,23 @@ export function runHarnessTests(
44
44
expect ( selects . length ) . toBe ( 4 ) ;
45
45
} ) ;
46
46
47
+ it ( 'should filter by whether a select is disabled' , async ( ) => {
48
+ let enabledSelects = await loader . getAllHarnesses ( selectHarness . with ( { disabled : false } ) ) ;
49
+ let disabledSelects = await loader . getAllHarnesses ( selectHarness . with ( { disabled : true } ) ) ;
50
+
51
+ expect ( enabledSelects . length ) . toBe ( 4 ) ;
52
+ expect ( disabledSelects . length ) . toBe ( 0 ) ;
53
+
54
+ fixture . componentInstance . isDisabled = true ;
55
+ fixture . detectChanges ( ) ;
56
+
57
+ enabledSelects = await loader . getAllHarnesses ( selectHarness . with ( { disabled : false } ) ) ;
58
+ disabledSelects = await loader . getAllHarnesses ( selectHarness . with ( { disabled : true } ) ) ;
59
+
60
+ expect ( enabledSelects . length ) . toBe ( 3 ) ;
61
+ expect ( disabledSelects . length ) . toBe ( 1 ) ;
62
+ } ) ;
63
+
47
64
it ( 'should be able to check whether a select is in multi-selection mode' , async ( ) => {
48
65
const singleSelection = await loader . getHarness (
49
66
selectHarness . with ( {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { _MatSelectHarnessBase } from '@angular/material/select/testing';
14
14
15
15
// @public @deprecated
16
16
export interface LegacySelectHarnessFilters extends BaseHarnessFilters {
17
+ disabled? : boolean ;
17
18
}
18
19
19
20
// @public @deprecated
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export abstract class _MatSelectHarnessBase<OptionType extends ComponentHarnessC
60
60
61
61
// @public
62
62
export interface SelectHarnessFilters extends BaseHarnessFilters {
63
+ disabled? : boolean ;
63
64
}
64
65
65
66
// (No @packageDocumentation comment for this package)
You can’t perform that action at this time.
0 commit comments