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 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
---|
10 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
11 | export class _MatSlideToggleHarnessBase extends ComponentHarness {
|
---|
12 | constructor() {
|
---|
13 | super(...arguments);
|
---|
14 | this._label = this.locatorFor('label');
|
---|
15 | this._input = this.locatorFor('input');
|
---|
16 | }
|
---|
17 | /** Whether the slide-toggle is checked. */
|
---|
18 | isChecked() {
|
---|
19 | return __awaiter(this, void 0, void 0, function* () {
|
---|
20 | const checked = (yield this._input()).getProperty('checked');
|
---|
21 | return coerceBooleanProperty(yield checked);
|
---|
22 | });
|
---|
23 | }
|
---|
24 | /** Whether the slide-toggle is disabled. */
|
---|
25 | isDisabled() {
|
---|
26 | return __awaiter(this, void 0, void 0, function* () {
|
---|
27 | const disabled = (yield this._input()).getAttribute('disabled');
|
---|
28 | return coerceBooleanProperty(yield disabled);
|
---|
29 | });
|
---|
30 | }
|
---|
31 | /** Whether the slide-toggle is required. */
|
---|
32 | isRequired() {
|
---|
33 | return __awaiter(this, void 0, void 0, function* () {
|
---|
34 | const required = (yield this._input()).getAttribute('required');
|
---|
35 | return coerceBooleanProperty(yield required);
|
---|
36 | });
|
---|
37 | }
|
---|
38 | /** Whether the slide-toggle is valid. */
|
---|
39 | isValid() {
|
---|
40 | return __awaiter(this, void 0, void 0, function* () {
|
---|
41 | const invalid = (yield this.host()).hasClass('ng-invalid');
|
---|
42 | return !(yield invalid);
|
---|
43 | });
|
---|
44 | }
|
---|
45 | /** Gets the slide-toggle's name. */
|
---|
46 | getName() {
|
---|
47 | return __awaiter(this, void 0, void 0, function* () {
|
---|
48 | return (yield this._input()).getAttribute('name');
|
---|
49 | });
|
---|
50 | }
|
---|
51 | /** Gets the slide-toggle's aria-label. */
|
---|
52 | getAriaLabel() {
|
---|
53 | return __awaiter(this, void 0, void 0, function* () {
|
---|
54 | return (yield this._input()).getAttribute('aria-label');
|
---|
55 | });
|
---|
56 | }
|
---|
57 | /** Gets the slide-toggle's aria-labelledby. */
|
---|
58 | getAriaLabelledby() {
|
---|
59 | return __awaiter(this, void 0, void 0, function* () {
|
---|
60 | return (yield this._input()).getAttribute('aria-labelledby');
|
---|
61 | });
|
---|
62 | }
|
---|
63 | /** Gets the slide-toggle's label text. */
|
---|
64 | getLabelText() {
|
---|
65 | return __awaiter(this, void 0, void 0, function* () {
|
---|
66 | return (yield this._label()).text();
|
---|
67 | });
|
---|
68 | }
|
---|
69 | /** Focuses the slide-toggle. */
|
---|
70 | focus() {
|
---|
71 | return __awaiter(this, void 0, void 0, function* () {
|
---|
72 | return (yield this._input()).focus();
|
---|
73 | });
|
---|
74 | }
|
---|
75 | /** Blurs the slide-toggle. */
|
---|
76 | blur() {
|
---|
77 | return __awaiter(this, void 0, void 0, function* () {
|
---|
78 | return (yield this._input()).blur();
|
---|
79 | });
|
---|
80 | }
|
---|
81 | /** Whether the slide-toggle is focused. */
|
---|
82 | isFocused() {
|
---|
83 | return __awaiter(this, void 0, void 0, function* () {
|
---|
84 | return (yield this._input()).isFocused();
|
---|
85 | });
|
---|
86 | }
|
---|
87 | /**
|
---|
88 | * Puts the slide-toggle in a checked state by toggling it if it is currently unchecked, or doing
|
---|
89 | * nothing if it is already checked.
|
---|
90 | */
|
---|
91 | check() {
|
---|
92 | return __awaiter(this, void 0, void 0, function* () {
|
---|
93 | if (!(yield this.isChecked())) {
|
---|
94 | yield this.toggle();
|
---|
95 | }
|
---|
96 | });
|
---|
97 | }
|
---|
98 | /**
|
---|
99 | * Puts the slide-toggle in an unchecked state by toggling it if it is currently checked, or doing
|
---|
100 | * nothing if it is already unchecked.
|
---|
101 | */
|
---|
102 | uncheck() {
|
---|
103 | return __awaiter(this, void 0, void 0, function* () {
|
---|
104 | if (yield this.isChecked()) {
|
---|
105 | yield this.toggle();
|
---|
106 | }
|
---|
107 | });
|
---|
108 | }
|
---|
109 | }
|
---|
110 | /** Harness for interacting with a standard mat-slide-toggle in tests. */
|
---|
111 | export class MatSlideToggleHarness extends _MatSlideToggleHarnessBase {
|
---|
112 | constructor() {
|
---|
113 | super(...arguments);
|
---|
114 | this._inputContainer = this.locatorFor('.mat-slide-toggle-bar');
|
---|
115 | }
|
---|
116 | /**
|
---|
117 | * Gets a `HarnessPredicate` that can be used to search for a `MatSlideToggleHarness` that meets
|
---|
118 | * certain criteria.
|
---|
119 | * @param options Options for filtering which slide toggle instances are considered a match.
|
---|
120 | * @return a `HarnessPredicate` configured with the given options.
|
---|
121 | */
|
---|
122 | static with(options = {}) {
|
---|
123 | return new HarnessPredicate(MatSlideToggleHarness, options)
|
---|
124 | .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label))
|
---|
125 | // We want to provide a filter option for "name" because the name of the slide-toggle is
|
---|
126 | // only set on the underlying input. This means that it's not possible for developers
|
---|
127 | // to retrieve the harness of a specific checkbox with name through a CSS selector.
|
---|
128 | .addOption('name', options.name, (harness, name) => __awaiter(this, void 0, void 0, function* () { return (yield harness.getName()) === name; }));
|
---|
129 | }
|
---|
130 | /** Toggle the checked state of the slide-toggle. */
|
---|
131 | toggle() {
|
---|
132 | return __awaiter(this, void 0, void 0, function* () {
|
---|
133 | return (yield this._inputContainer()).click();
|
---|
134 | });
|
---|
135 | }
|
---|
136 | }
|
---|
137 | /** The selector for the host element of a `MatSlideToggle` instance. */
|
---|
138 | MatSlideToggleHarness.hostSelector = '.mat-slide-toggle';
|
---|
139 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xpZGUtdG9nZ2xlLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8u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