source: trip-planner-front/node_modules/@angular/material/fesm2015/badge/testing.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: 3.7 KB
Line 
1import { __awaiter } from 'tslib';
2import { ComponentHarness, HarnessPredicate } 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 Material badge in tests. */
12class MatBadgeHarness extends ComponentHarness {
13 constructor() {
14 super(...arguments);
15 this._badgeElement = this.locatorFor('.mat-badge-content');
16 }
17 /**
18 * Gets a `HarnessPredicate` that can be used to search for a badge with specific attributes.
19 * @param options Options for narrowing the search:
20 * - `text` finds a badge host with a particular text.
21 * @return a `HarnessPredicate` configured with the given options.
22 */
23 static with(options = {}) {
24 return new HarnessPredicate(MatBadgeHarness, options)
25 .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text));
26 }
27 /** Gets a promise for the badge text. */
28 getText() {
29 return __awaiter(this, void 0, void 0, function* () {
30 return (yield this._badgeElement()).text();
31 });
32 }
33 /** Gets whether the badge is overlapping the content. */
34 isOverlapping() {
35 return __awaiter(this, void 0, void 0, function* () {
36 return (yield this.host()).hasClass('mat-badge-overlap');
37 });
38 }
39 /** Gets the position of the badge. */
40 getPosition() {
41 return __awaiter(this, void 0, void 0, function* () {
42 const host = yield this.host();
43 let result = '';
44 if (yield host.hasClass('mat-badge-above')) {
45 result += 'above';
46 }
47 else if (yield host.hasClass('mat-badge-below')) {
48 result += 'below';
49 }
50 if (yield host.hasClass('mat-badge-before')) {
51 result += ' before';
52 }
53 else if (yield host.hasClass('mat-badge-after')) {
54 result += ' after';
55 }
56 return result.trim();
57 });
58 }
59 /** Gets the size of the badge. */
60 getSize() {
61 return __awaiter(this, void 0, void 0, function* () {
62 const host = yield this.host();
63 if (yield host.hasClass('mat-badge-small')) {
64 return 'small';
65 }
66 else if (yield host.hasClass('mat-badge-large')) {
67 return 'large';
68 }
69 return 'medium';
70 });
71 }
72 /** Gets whether the badge is hidden. */
73 isHidden() {
74 return __awaiter(this, void 0, void 0, function* () {
75 return (yield this.host()).hasClass('mat-badge-hidden');
76 });
77 }
78 /** Gets whether the badge is disabled. */
79 isDisabled() {
80 return __awaiter(this, void 0, void 0, function* () {
81 return (yield this.host()).hasClass('mat-badge-disabled');
82 });
83 }
84}
85MatBadgeHarness.hostSelector = '.mat-badge';
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/**
96 * @license
97 * Copyright Google LLC All Rights Reserved.
98 *
99 * Use of this source code is governed by an MIT-style license that can be
100 * found in the LICENSE file at https://angular.io/license
101 */
102
103/**
104 * @license
105 * Copyright Google LLC All Rights Reserved.
106 *
107 * Use of this source code is governed by an MIT-style license that can be
108 * found in the LICENSE file at https://angular.io/license
109 */
110
111export { MatBadgeHarness };
112//# sourceMappingURL=testing.js.map
Note: See TracBrowser for help on using the repository browser.