1 | import { __awaiter } from 'tslib';
|
2 | import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
3 |
|
4 |
|
5 | class MatOptionHarness extends ComponentHarness {
|
6 | constructor() {
|
7 | super(...arguments);
|
8 |
|
9 | this._text = this.locatorFor('.mat-option-text');
|
10 | }
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | static with(options = {}) {
|
18 | return new HarnessPredicate(MatOptionHarness, options)
|
19 | .addOption('text', options.text, (harness, title) => __awaiter(this, void 0, void 0, function* () { return HarnessPredicate.stringMatches(yield harness.getText(), title); }))
|
20 | .addOption('isSelected', options.isSelected, (harness, isSelected) => __awaiter(this, void 0, void 0, function* () { return (yield harness.isSelected()) === isSelected; }));
|
21 | }
|
22 |
|
23 | click() {
|
24 | return __awaiter(this, void 0, void 0, function* () {
|
25 | return (yield this.host()).click();
|
26 | });
|
27 | }
|
28 |
|
29 | getText() {
|
30 | return __awaiter(this, void 0, void 0, function* () {
|
31 | return (yield this._text()).text();
|
32 | });
|
33 | }
|
34 |
|
35 | isDisabled() {
|
36 | return __awaiter(this, void 0, void 0, function* () {
|
37 | return (yield this.host()).hasClass('mat-option-disabled');
|
38 | });
|
39 | }
|
40 |
|
41 | isSelected() {
|
42 | return __awaiter(this, void 0, void 0, function* () {
|
43 | return (yield this.host()).hasClass('mat-selected');
|
44 | });
|
45 | }
|
46 |
|
47 | isActive() {
|
48 | return __awaiter(this, void 0, void 0, function* () {
|
49 | return (yield this.host()).hasClass('mat-active');
|
50 | });
|
51 | }
|
52 |
|
53 | isMultiple() {
|
54 | return __awaiter(this, void 0, void 0, function* () {
|
55 | return (yield this.host()).hasClass('mat-option-multiple');
|
56 | });
|
57 | }
|
58 | }
|
59 |
|
60 | MatOptionHarness.hostSelector = '.mat-option';
|
61 |
|
62 |
|
63 | class MatOptgroupHarness extends ComponentHarness {
|
64 | constructor() {
|
65 | super(...arguments);
|
66 | this._label = this.locatorFor('.mat-optgroup-label');
|
67 | }
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | static with(options = {}) {
|
75 | return new HarnessPredicate(MatOptgroupHarness, options).addOption('labelText', options.labelText, (harness, title) => __awaiter(this, void 0, void 0, function* () { return HarnessPredicate.stringMatches(yield harness.getLabelText(), title); }));
|
76 | }
|
77 |
|
78 | getLabelText() {
|
79 | return __awaiter(this, void 0, void 0, function* () {
|
80 | return (yield this._label()).text();
|
81 | });
|
82 | }
|
83 |
|
84 | isDisabled() {
|
85 | return __awaiter(this, void 0, void 0, function* () {
|
86 | return (yield this.host()).hasClass('mat-optgroup-disabled');
|
87 | });
|
88 | }
|
89 | |
90 |
|
91 |
|
92 |
|
93 | getOptions(filter = {}) {
|
94 | return __awaiter(this, void 0, void 0, function* () {
|
95 | return this.locatorForAll(MatOptionHarness.with(filter))();
|
96 | });
|
97 | }
|
98 | }
|
99 |
|
100 | MatOptgroupHarness.hostSelector = '.mat-optgroup';
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | export { MatOptgroupHarness, MatOptionHarness };
|
119 |
|