source: trip-planner-front/node_modules/@angular/material/esm2015/snack-bar/testing/snack-bar-harness.js@ 84d0fbb

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

initial commit

  • Property mode set to 100644
File size: 15.6 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, parallel } from '@angular/cdk/testing';
10/** Harness for interacting with a standard mat-snack-bar in tests. */
11export class MatSnackBarHarness extends ContentContainerComponentHarness {
12 constructor() {
13 super(...arguments);
14 this._messageSelector = '.mat-simple-snackbar > span';
15 this._actionButtonSelector = '.mat-simple-snackbar-action > button';
16 this._snackBarLiveRegion = this.locatorFor('[aria-live]');
17 }
18 /**
19 * Gets a `HarnessPredicate` that can be used to search for a `MatSnackBarHarness` that meets
20 * certain criteria.
21 * @param options Options for filtering which snack bar instances are considered a match.
22 * @return a `HarnessPredicate` configured with the given options.
23 */
24 static with(options = {}) {
25 return new HarnessPredicate(MatSnackBarHarness, options);
26 }
27 /**
28 * Gets the role of the snack-bar. The role of a snack-bar is determined based
29 * on the ARIA politeness specified in the snack-bar config.
30 * @deprecated Use `getAriaLive` instead.
31 * @breaking-change 13.0.0
32 */
33 getRole() {
34 return __awaiter(this, void 0, void 0, function* () {
35 return (yield this.host()).getAttribute('role');
36 });
37 }
38 /**
39 * Gets the aria-live of the snack-bar's live region. The aria-live of a snack-bar is
40 * determined based on the ARIA politeness specified in the snack-bar config.
41 */
42 getAriaLive() {
43 return __awaiter(this, void 0, void 0, function* () {
44 return (yield this._snackBarLiveRegion())
45 .getAttribute('aria-live');
46 });
47 }
48 /**
49 * Whether the snack-bar has an action. Method cannot be used for snack-bar's with custom content.
50 */
51 hasAction() {
52 return __awaiter(this, void 0, void 0, function* () {
53 yield this._assertContentAnnotated();
54 return (yield this._getActionButton()) !== null;
55 });
56 }
57 /**
58 * Gets the description of the snack-bar. Method cannot be used for snack-bar's without action or
59 * with custom content.
60 */
61 getActionDescription() {
62 return __awaiter(this, void 0, void 0, function* () {
63 yield this._assertHasAction();
64 return (yield this._getActionButton()).text();
65 });
66 }
67 /**
68 * Dismisses the snack-bar by clicking the action button. Method cannot be used for snack-bar's
69 * without action or with custom content.
70 */
71 dismissWithAction() {
72 return __awaiter(this, void 0, void 0, function* () {
73 yield this._assertHasAction();
74 yield (yield this._getActionButton()).click();
75 });
76 }
77 /**
78 * Gets the message of the snack-bar. Method cannot be used for snack-bar's with custom content.
79 */
80 getMessage() {
81 return __awaiter(this, void 0, void 0, function* () {
82 yield this._assertContentAnnotated();
83 return (yield this.locatorFor(this._messageSelector)()).text();
84 });
85 }
86 /** Gets whether the snack-bar has been dismissed. */
87 isDismissed() {
88 return __awaiter(this, void 0, void 0, function* () {
89 // We consider the snackbar dismissed if it's not in the DOM. We can assert that the
90 // element isn't in the DOM by seeing that its width and height are zero.
91 const host = yield this.host();
92 const [exit, dimensions] = yield parallel(() => [
93 // The snackbar container is marked with the "exit" attribute after it has been dismissed
94 // but before the animation has finished (after which it's removed from the DOM).
95 host.getAttribute('mat-exit'),
96 host.getDimensions(),
97 ]);
98 return exit != null || (!!dimensions && dimensions.height === 0 && dimensions.width === 0);
99 });
100 }
101 /**
102 * Asserts that the current snack-bar has annotated content. Promise reject
103 * if content is not annotated.
104 */
105 _assertContentAnnotated() {
106 return __awaiter(this, void 0, void 0, function* () {
107 if (!(yield this._isSimpleSnackBar())) {
108 throw Error('Method cannot be used for snack-bar with custom content.');
109 }
110 });
111 }
112 /**
113 * Asserts that the current snack-bar has an action defined. Otherwise the
114 * promise will reject.
115 */
116 _assertHasAction() {
117 return __awaiter(this, void 0, void 0, function* () {
118 yield this._assertContentAnnotated();
119 if (!(yield this.hasAction())) {
120 throw Error('Method cannot be used for a snack-bar without an action.');
121 }
122 });
123 }
124 /** Whether the snack-bar is using the default content template. */
125 _isSimpleSnackBar() {
126 return __awaiter(this, void 0, void 0, function* () {
127 return (yield this.locatorForOptional('.mat-simple-snackbar')()) !== null;
128 });
129 }
130 /** Gets the simple snack bar action button. */
131 _getActionButton() {
132 return __awaiter(this, void 0, void 0, function* () {
133 return this.locatorForOptional(this._actionButtonSelector)();
134 });
135 }
136}
137// Developers can provide a custom component or template for the
138// snackbar. The canonical snack-bar parent is the "MatSnackBarContainer".
139/** The selector for the host element of a `MatSnackBar` instance. */
140MatSnackBarHarness.hostSelector = '.mat-snack-bar-container';
141//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25hY2stYmFyLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc25hY2stYmFyL3Rlc3Rpbmcvc25hY2stYmFyLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUdILE9BQU8sRUFBQyxnQ0FBZ0MsRUFBRSxnQkFBZ0IsRUFBRSxRQUFRLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUdsRyxzRUFBc0U7QUFDdEUsTUFBTSxPQUFPLGtCQUFtQixTQUFRLGdDQUF3QztJQUFoRjs7UUFLWSxxQkFBZ0IsR0FBRyw2QkFBNkIsQ0FBQztRQUNqRCwwQkFBcUIsR0FBRyxzQ0FBc0MsQ0FBQztRQUNqRSx3QkFBbUIsR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0lBZ0gvRCxDQUFDO0lBOUdDOzs7OztPQUtHO0lBQ0gsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFrQyxFQUFFO1FBQzlDLE9BQU8sSUFBSSxnQkFBZ0IsQ0FBQyxrQkFBa0IsRUFBRSxPQUFPLENBQUMsQ0FBQztJQUMzRCxDQUFDO0lBRUQ7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ZpbmVkLiBPdGhlcndpc2UgdGhlXG4gICAqIHByb21pc2Ugd2lsbCByZWplY3QuXG4gICAqL1xuICBwcm90ZWN0ZWQgYXN5bmMgX2Fzc2VydEhhc0FjdGlvbigpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICBhd2FpdCB0aGlzLl9hc3NlcnRDb250ZW50QW5ub3RhdGVkKCk7XG4gICAgaWYgKCFhd2FpdCB0aGlzLmhhc0FjdGlvbigpKSB7XG4gICAgICB0aHJvdyBFcnJvcignTWV0aG9kIGNhbm5vdCBiZSB1c2VkIGZvciBhIHNuYWNrLWJhciB3aXRob3V0IGFuIGFjdGlvbi4nKTtcbiAgICB9XG4gIH1cblxuICAvKiogV2hldGhlciB0aGUgc25hY2stYmFyIGlzIHVzaW5nIHRoZSBkZWZhdWx0IGNvbnRlbnQgdGVtcGxhdGUuICovXG4gIHByaXZhdGUgYXN5bmMgX2lzU2ltcGxlU25hY2tCYXIoKTogUHJvbWlzZTxib29sZWFuPiB7XG4gICAgcmV0dXJuIGF3YWl0IHRoaXMubG9jYXRvckZvck9wdGlvbmFsKCcubWF0LXNpbXBsZS1zbmFja2JhcicpKCkgIT09IG51bGw7XG4gIH1cblxuICAvKiogR2V0cyB0aGUgc2ltcGxlIHNuYWNrIGJhciBhY3Rpb24gYnV0dG9uLiAqL1xuICBwcml2YXRlIGFzeW5jIF9nZXRBY3Rpb25CdXR0b24oKSB7XG4gICAgcmV0dXJuIHRoaXMubG9jYXRvckZvck9wdGlvbmFsKHRoaXMuX2FjdGlvbkJ1dHRvblNlbGVjdG9yKSgpO1xuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.