source: trip-planner-front/node_modules/@angular/material/esm2015/dialog/testing/dialog-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.9 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, TestKey } from '@angular/cdk/testing';
10/** Harness for interacting with a standard `MatDialog` in tests. */
11export class MatDialogHarness extends ContentContainerComponentHarness {
12 /**
13 * Gets a `HarnessPredicate` that can be used to search for a `MatDialogHarness` that meets
14 * certain criteria.
15 * @param options Options for filtering which dialog instances are considered a match.
16 * @return a `HarnessPredicate` configured with the given options.
17 */
18 static with(options = {}) {
19 return new HarnessPredicate(MatDialogHarness, options);
20 }
21 /** Gets the id of the dialog. */
22 getId() {
23 return __awaiter(this, void 0, void 0, function* () {
24 const id = yield (yield this.host()).getAttribute('id');
25 // In case no id has been specified, the "id" property always returns
26 // an empty string. To make this method more explicit, we return null.
27 return id !== '' ? id : null;
28 });
29 }
30 /** Gets the role of the dialog. */
31 getRole() {
32 return __awaiter(this, void 0, void 0, function* () {
33 return (yield this.host()).getAttribute('role');
34 });
35 }
36 /** Gets the value of the dialog's "aria-label" attribute. */
37 getAriaLabel() {
38 return __awaiter(this, void 0, void 0, function* () {
39 return (yield this.host()).getAttribute('aria-label');
40 });
41 }
42 /** Gets the value of the dialog's "aria-labelledby" attribute. */
43 getAriaLabelledby() {
44 return __awaiter(this, void 0, void 0, function* () {
45 return (yield this.host()).getAttribute('aria-labelledby');
46 });
47 }
48 /** Gets the value of the dialog's "aria-describedby" attribute. */
49 getAriaDescribedby() {
50 return __awaiter(this, void 0, void 0, function* () {
51 return (yield this.host()).getAttribute('aria-describedby');
52 });
53 }
54 /**
55 * Closes the dialog by pressing escape.
56 *
57 * Note: this method does nothing if `disableClose` has been set to `true` for the dialog.
58 */
59 close() {
60 return __awaiter(this, void 0, void 0, function* () {
61 yield (yield this.host()).sendKeys(TestKey.ESCAPE);
62 });
63 }
64}
65// Developers can provide a custom component or template for the
66// dialog. The canonical dialog parent is the "MatDialogContainer".
67/** The selector for the host element of a `MatDialog` instance. */
68MatDialogHarness.hostSelector = '.mat-dialog-container';
69//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlhbG9nLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZGlhbG9nL3Rlc3RpbmcvZGlhbG9nLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBQyxnQ0FBZ0MsRUFBRSxnQkFBZ0IsRUFBRSxPQUFPLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUlqRyxvRUFBb0U7QUFDcEUsTUFBTSxPQUFPLGdCQUFpQixTQUFRLGdDQUF3QztJQU01RTs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBZ0MsRUFBRTtRQUM1QyxPQUFPLElBQUksZ0JBQWdCLENBQUMsZ0JBQWdCLEVBQUUsT0FBTyxDQUFDLENBQUM7SUFDekQsQ0FBQztJQUVELGlDQUFpQztJQUMzQixLQUFLOztZQUNULE1BQU0sRUFBRSxHQUFHLE1BQU0sQ0FBQyxNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsQ0FBQztZQUN4RCxxRUFBcUU7WUFDckUsc0VBQXNFO1lBQ3RFLE9BQU8sRUFBRSxLQUFLLEVBQUUsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUM7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