API reference for Angular Material button-toggle-testing

import {MatButtonToggleHarness} from '@angular/material/button-toggle/testing';

Harness for interacting with a standard mat-button-toggle in tests.

Properties
Name Description

static hostSelector: '.mat-button-toggle'

The selector for the host element of a MatButton instance.

Methods
async
blur (): Promise<void>

Blurs the toggle.

Returns
Promise<void>

Promise that resolves when the action completes.

async
check (): Promise<void>

Puts the button toggle in a checked state by toggling it if it's currently unchecked, or doing nothing if it is already checked.

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus (): Promise<void>

Focuses the toggle.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAppearance (): Promise<MatButtonToggleAppearance>

Gets the appearance that the button toggle is using.

Returns
Promise<MatButtonToggleAppearance>

async
getAriaLabel (): Promise<string | null>

Gets a promise for the button toggle's aria-label.

Returns
Promise<string | null>

async
getAriaLabelledby (): Promise<string | null>

Gets a promise for the button toggles's aria-labelledby.

Returns
Promise<string | null>

async
getName (): Promise<string | null>

Gets a promise for the button toggle's name.

Returns
Promise<string | null>

async
getText (): Promise<string>

Gets a promise for the button toggle's text.

Returns
Promise<string>

async
host (): Promise<TestElement>

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isChecked (): Promise<boolean>

Gets a boolean promise indicating if the button toggle is checked.

Returns
Promise<boolean>

async
isDisabled (): Promise<boolean>

Gets a boolean promise indicating if the button toggle is disabled.

Returns
Promise<boolean>

async
isFocused (): Promise<boolean>

Whether the toggle is focused.

Returns
Promise<boolean>

async
toggle (): Promise<void>

Toggle the checked state of the buttons toggle.

Returns
Promise<void>

Promise that resolves when the action completes.

async
uncheck (): Promise<void>

Puts the button toggle in an unchecked state by toggling it if it's currently checked, or doing nothing if it's already unchecked.

Returns
Promise<void>

Promise that resolves when the action completes.

static
with (options: ButtonToggleHarnessFilters = {}): HarnessPredicate<MatButtonToggleHarness>

Gets a HarnessPredicate that can be used to search for a MatButtonToggleHarness that meets certain criteria.

Parameters

options

ButtonToggleHarnessFilters = {}

Options for filtering which button toggle instances are considered a match.

Returns
HarnessPredicate<MatButtonToggleHarness>

a HarnessPredicate configured with the given options.

Harness for interacting with a standard mat-button-toggle in tests.

Properties
Name Description

static hostSelector: '.mat-button-toggle-group'

The selector for the host element of a MatButton instance.

Methods
async
getAppearance (): Promise<MatButtonToggleAppearance>

Gets the appearance that the group is using.

Returns
Promise<MatButtonToggleAppearance>

async
getToggles (filter: ButtonToggleHarnessFilters = {}): Promise<MatButtonToggleHarness[]>

Gets the button toggles that are inside the group.

Parameters

filter

ButtonToggleHarnessFilters = {}

Optionally filters which toggles are included.

Returns
Promise<MatButtonToggleHarness[]>

async
host (): Promise<TestElement>

Gets a Promise for the TestElement representing the host element of the component.

Returns
Promise<TestElement>

async
isDisabled (): Promise<boolean>

Gets whether the button toggle group is disabled.

Returns
Promise<boolean>

async
isVertical (): Promise<boolean>

Gets whether the button toggle group is laid out vertically.

Returns
Promise<boolean>

static
with (options: ButtonToggleGroupHarnessFilters = {}): HarnessPredicate<MatButtonToggleGroupHarness>

Gets a HarnessPredicate that can be used to search for a MatButtonToggleGroupHarness that meets certain criteria.

Parameters

options

ButtonToggleGroupHarnessFilters = {}

Options for filtering which button toggle instances are considered a match.

Returns
HarnessPredicate<MatButtonToggleGroupHarness>

a HarnessPredicate configured with the given options.

Criteria that can be used to filter a list of MatButtonToggleHarness instances.

Properties
Name Description

checked: boolean

Only find instances that are checked.

disabled: boolean

Only find instances which match the given disabled state.

name: string | RegExp

Only find instances whose name matches the given value.

text: string | RegExp

Only find instances whose text matches the given value.

Criteria that can be used to filter a list of MatButtonToggleGroupHarness instances.

Properties
Name Description

disabled: boolean

Only find instances which match the given disabled state.