MCPcopy Create free account
hub / github.com/angular/components / with

Method with

src/material/button/testing/button-harness.ts:43–67  ·  view source on GitHub ↗

* 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 = {},
  )

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 8

addOptionMethod · 0.80
stringMatchesMethod · 0.80
getVariantMethod · 0.80
locatorForOptionalMethod · 0.80
getTextMethod · 0.45
getAppearanceMethod · 0.45
isDisabledMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected