You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.1 KiB
91 lines
3.1 KiB
import { __awaiter } from 'tslib';
|
|
import { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
/** Harness for interacting with a standard mat-button in tests. */
|
|
class MatButtonHarness extends ContentContainerComponentHarness {
|
|
/**
|
|
* Gets a `HarnessPredicate` that can be used to search for a `MatButtonHarness` that meets
|
|
* certain criteria.
|
|
* @param options Options for filtering which button instances are considered a match.
|
|
* @return a `HarnessPredicate` configured with the given options.
|
|
*/
|
|
static with(options = {}) {
|
|
return new HarnessPredicate(MatButtonHarness, options)
|
|
.addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text));
|
|
}
|
|
click(...args) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).click(...args);
|
|
});
|
|
}
|
|
/** Whether the button is disabled. */
|
|
isDisabled() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const disabled = (yield this.host()).getAttribute('disabled');
|
|
return coerceBooleanProperty(yield disabled);
|
|
});
|
|
}
|
|
/** Gets the button's label text. */
|
|
getText() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).text();
|
|
});
|
|
}
|
|
/** Focuses the button. */
|
|
focus() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).focus();
|
|
});
|
|
}
|
|
/** Blurs the button. */
|
|
blur() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).blur();
|
|
});
|
|
}
|
|
/** Whether the button is focused. */
|
|
isFocused() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).isFocused();
|
|
});
|
|
}
|
|
}
|
|
// TODO(jelbourn) use a single class, like `.mat-button-base`
|
|
/** The selector for the host element of a `MatButton` instance. */
|
|
MatButtonHarness.hostSelector = `[mat-button], [mat-raised-button], [mat-flat-button], [mat-icon-button],
|
|
[mat-stroked-button], [mat-fab], [mat-mini-fab]`;
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
export { MatButtonHarness };
|
|
//# sourceMappingURL=testing.js.map
|