[6a3a178] | 1 | import { __awaiter } from 'tslib';
|
---|
| 2 | import { ContentContainerComponentHarness, HarnessPredicate, TestKey } from '@angular/cdk/testing';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * @license
|
---|
| 6 | * Copyright Google LLC All Rights Reserved.
|
---|
| 7 | *
|
---|
| 8 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 9 | * found in the LICENSE file at https://angular.io/license
|
---|
| 10 | */
|
---|
| 11 | /** Harness for interacting with a standard `MatDialog` in tests. */
|
---|
| 12 | class MatDialogHarness extends ContentContainerComponentHarness {
|
---|
| 13 | /**
|
---|
| 14 | * Gets a `HarnessPredicate` that can be used to search for a `MatDialogHarness` that meets
|
---|
| 15 | * certain criteria.
|
---|
| 16 | * @param options Options for filtering which dialog instances are considered a match.
|
---|
| 17 | * @return a `HarnessPredicate` configured with the given options.
|
---|
| 18 | */
|
---|
| 19 | static with(options = {}) {
|
---|
| 20 | return new HarnessPredicate(MatDialogHarness, options);
|
---|
| 21 | }
|
---|
| 22 | /** Gets the id of the dialog. */
|
---|
| 23 | getId() {
|
---|
| 24 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 25 | const id = yield (yield this.host()).getAttribute('id');
|
---|
| 26 | // In case no id has been specified, the "id" property always returns
|
---|
| 27 | // an empty string. To make this method more explicit, we return null.
|
---|
| 28 | return id !== '' ? id : null;
|
---|
| 29 | });
|
---|
| 30 | }
|
---|
| 31 | /** Gets the role of the dialog. */
|
---|
| 32 | getRole() {
|
---|
| 33 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 34 | return (yield this.host()).getAttribute('role');
|
---|
| 35 | });
|
---|
| 36 | }
|
---|
| 37 | /** Gets the value of the dialog's "aria-label" attribute. */
|
---|
| 38 | getAriaLabel() {
|
---|
| 39 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 40 | return (yield this.host()).getAttribute('aria-label');
|
---|
| 41 | });
|
---|
| 42 | }
|
---|
| 43 | /** Gets the value of the dialog's "aria-labelledby" attribute. */
|
---|
| 44 | getAriaLabelledby() {
|
---|
| 45 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 46 | return (yield this.host()).getAttribute('aria-labelledby');
|
---|
| 47 | });
|
---|
| 48 | }
|
---|
| 49 | /** Gets the value of the dialog's "aria-describedby" attribute. */
|
---|
| 50 | getAriaDescribedby() {
|
---|
| 51 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 52 | return (yield this.host()).getAttribute('aria-describedby');
|
---|
| 53 | });
|
---|
| 54 | }
|
---|
| 55 | /**
|
---|
| 56 | * Closes the dialog by pressing escape.
|
---|
| 57 | *
|
---|
| 58 | * Note: this method does nothing if `disableClose` has been set to `true` for the dialog.
|
---|
| 59 | */
|
---|
| 60 | close() {
|
---|
| 61 | return __awaiter(this, void 0, void 0, function* () {
|
---|
| 62 | yield (yield this.host()).sendKeys(TestKey.ESCAPE);
|
---|
| 63 | });
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | // Developers can provide a custom component or template for the
|
---|
| 67 | // dialog. The canonical dialog parent is the "MatDialogContainer".
|
---|
| 68 | /** The selector for the host element of a `MatDialog` instance. */
|
---|
| 69 | MatDialogHarness.hostSelector = '.mat-dialog-container';
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | * @license
|
---|
| 73 | * Copyright Google LLC All Rights Reserved.
|
---|
| 74 | *
|
---|
| 75 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 76 | * found in the LICENSE file at https://angular.io/license
|
---|
| 77 | */
|
---|
| 78 |
|
---|
| 79 | /**
|
---|
| 80 | * @license
|
---|
| 81 | * Copyright Google LLC All Rights Reserved.
|
---|
| 82 | *
|
---|
| 83 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 84 | * found in the LICENSE file at https://angular.io/license
|
---|
| 85 | */
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * @license
|
---|
| 89 | * Copyright Google LLC All Rights Reserved.
|
---|
| 90 | *
|
---|
| 91 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 92 | * found in the LICENSE file at https://angular.io/license
|
---|
| 93 | */
|
---|
| 94 |
|
---|
| 95 | export { MatDialogHarness };
|
---|
| 96 | //# sourceMappingURL=testing.js.map
|
---|