* Gets a `HarnessPredicate` that can be used to search for a button with specific attributes. * @param options Options for narrowing the search: * - `selector` finds a button whose host element matches the given selector. * - `text` finds a button with specific text content. * - `v
(
this: ComponentHarnessConstructor<T>,
options: ButtonHarnessFilters = {},
)
| 41 | * @return a `HarnessPredicate` configured with the given options. |
| 42 | */ |
| 43 | static with<T extends MatButtonHarness>( |
| 44 | this: ComponentHarnessConstructor<T>, |
| 45 | options: ButtonHarnessFilters = {}, |
| 46 | ): HarnessPredicate<T> { |
| 47 | return new HarnessPredicate(this, options) |
| 48 | .addOption('text', options.text, (harness, text) => |
| 49 | HarnessPredicate.stringMatches(harness.getText(), text), |
| 50 | ) |
| 51 | .addOption('variant', options.variant, (harness, variant) => |
| 52 | HarnessPredicate.stringMatches(harness.getVariant(), variant), |
| 53 | ) |
| 54 | .addOption('appearance', options.appearance, (harness, appearance) => |
| 55 | HarnessPredicate.stringMatches(harness.getAppearance(), appearance), |
| 56 | ) |
| 57 | .addOption('disabled', options.disabled, async (harness, disabled) => { |
| 58 | return (await harness.isDisabled()) === disabled; |
| 59 | }) |
| 60 | .addOption('buttonType', options.buttonType, (harness, buttonType) => |
| 61 | HarnessPredicate.stringMatches(harness.getType(), buttonType), |
| 62 | ) |
| 63 | .addOption('iconName', options.iconName, async (harness, iconName) => { |
| 64 | const result = await harness.locatorForOptional(MatIconHarness.with({name: iconName}))(); |
| 65 | return result !== null; |
| 66 | }); |
| 67 | } |
| 68 | |
| 69 | private readonly _progressIndicator = this.locatorForOptional('[progressIndicator]'); |
| 70 |
no test coverage detected