source: trip-planner-front/node_modules/@angular/material/esm2015/button/testing/button-harness.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 7.8 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
10import { coerceBooleanProperty } from '@angular/cdk/coercion';
11/** Harness for interacting with a standard mat-button in tests. */
12export class MatButtonHarness extends ContentContainerComponentHarness {
13 /**
14 * Gets a `HarnessPredicate` that can be used to search for a `MatButtonHarness` that meets
15 * certain criteria.
16 * @param options Options for filtering which button instances are considered a match.
17 * @return a `HarnessPredicate` configured with the given options.
18 */
19 static with(options = {}) {
20 return new HarnessPredicate(MatButtonHarness, options)
21 .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text));
22 }
23 click(...args) {
24 return __awaiter(this, void 0, void 0, function* () {
25 return (yield this.host()).click(...args);
26 });
27 }
28 /** Whether the button is disabled. */
29 isDisabled() {
30 return __awaiter(this, void 0, void 0, function* () {
31 const disabled = (yield this.host()).getAttribute('disabled');
32 return coerceBooleanProperty(yield disabled);
33 });
34 }
35 /** Gets the button's label text. */
36 getText() {
37 return __awaiter(this, void 0, void 0, function* () {
38 return (yield this.host()).text();
39 });
40 }
41 /** Focuses the button. */
42 focus() {
43 return __awaiter(this, void 0, void 0, function* () {
44 return (yield this.host()).focus();
45 });
46 }
47 /** Blurs the button. */
48 blur() {
49 return __awaiter(this, void 0, void 0, function* () {
50 return (yield this.host()).blur();
51 });
52 }
53 /** Whether the button is focused. */
54 isFocused() {
55 return __awaiter(this, void 0, void 0, function* () {
56 return (yield this.host()).isFocused();
57 });
58 }
59}
60// TODO(jelbourn) use a single class, like `.mat-button-base`
61/** The selector for the host element of a `MatButton` instance. */
62MatButtonHarness.hostSelector = `[mat-button], [mat-raised-button], [mat-flat-button], [mat-icon-button],
63 [mat-stroked-button], [mat-fab], [mat-mini-fab]`;
64//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnV0dG9uLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvYnV0dG9uL3Rlc3RpbmcvYnV0dG9uLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBQyxnQ0FBZ0MsRUFBRSxnQkFBZ0IsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQ3hGLE9BQU8sRUFBQyxxQkFBcUIsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBSTVELG1FQUFtRTtBQUNuRSxNQUFNLE9BQU8sZ0JBQWlCLFNBQVEsZ0NBQWdDO0lBTXBFOzs7OztPQUtHO0lBQ0gsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFnQyxFQUFFO1FBQzVDLE9BQU8sSUFBSSxnQkFBZ0IsQ0FBQyxnQkFBZ0IsRUFBRSxPQUFPLENBQUM7YUFDakQsU0FBUyxDQUFDLE1BQU0sRUFBRSxPQUFPLENBQUMsSUFBSSxFQUMzQixDQUFDLE9BQU8sRUFBRSxJQUFJLEVBQUUsRUFBRSxDQUFDLGdCQUFnQixDQUFDLGFBQWEsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQztJQUN0RixDQUFDO0lBWUssS0FBSyxDQUFDLEdBQUcsSUFBd0M7O1lBQ3JELE9BQU8sQ0FBQyxNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDLEtBQUssQ0FBQyxHQUFJLElBQVcsQ0FBQyxDQUFDO1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