@spectrum-web-components/textfield 0.11.10 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +37 -37
- package/package.json +25 -12
- package/sp-textfield.dev.js +3 -0
- package/sp-textfield.dev.js.map +7 -0
- package/sp-textfield.js +3 -14
- package/sp-textfield.js.map +7 -1
- package/src/Textfield.dev.js +291 -0
- package/src/Textfield.dev.js.map +7 -0
- package/src/Textfield.js +230 -249
- package/src/Textfield.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/spectrum-textfield.css.dev.js +252 -0
- package/src/spectrum-textfield.css.dev.js.map +7 -0
- package/src/spectrum-textfield.css.js +3 -14
- package/src/spectrum-textfield.css.js.map +7 -1
- package/src/textfield.css.dev.js +259 -0
- package/src/textfield.css.dev.js.map +7 -0
- package/src/textfield.css.js +3 -14
- package/src/textfield.css.js.map +7 -1
- package/stories/textarea.stories.js +15 -26
- package/stories/textarea.stories.js.map +7 -1
- package/stories/textfield.stories.js +15 -26
- package/stories/textfield.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +5 -16
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/textarea.test-vrt.js +4 -15
- package/test/textarea.test-vrt.js.map +7 -1
- package/test/textfield.test-vrt.js +4 -15
- package/test/textfield.test-vrt.js.map +7 -1
- package/test/textfield.test.js +464 -516
- package/test/textfield.test.js.map +7 -1
package/test/textfield.test.js
CHANGED
|
@@ -1,106 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
describe(
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { elementUpdated, expect, html, litFixture } from "@open-wc/testing";
|
|
2
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
3
|
+
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
4
|
+
import { findDescribedNode } from "../../../test/testing-helpers-a11y.js";
|
|
5
|
+
import "@spectrum-web-components/help-text/sp-help-text.js";
|
|
6
|
+
import "@spectrum-web-components/textfield/sp-textfield.js";
|
|
7
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
8
|
+
describe("Textfield", () => {
|
|
9
|
+
testForLitDevWarnings(async () => await litFixture(html`
|
|
10
|
+
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
11
|
+
`));
|
|
12
|
+
it("loads default textfield accessibly", async () => {
|
|
13
|
+
const el = await litFixture(html`
|
|
11
14
|
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
12
15
|
`);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
await elementUpdated(el);
|
|
17
|
+
await expect(el).to.be.accessible();
|
|
18
|
+
});
|
|
19
|
+
it("loads multiline textfield accessibly", async () => {
|
|
20
|
+
const el = await litFixture(html`
|
|
18
21
|
<sp-textfield label="Enter your name" multiline></sp-textfield>
|
|
19
22
|
`);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
await elementUpdated(el);
|
|
24
|
+
await expect(el).to.be.accessible();
|
|
25
|
+
});
|
|
26
|
+
it("manages tabIndex while disabled", async () => {
|
|
27
|
+
const el = await litFixture(html`
|
|
25
28
|
<sp-textfield placeholder="Enter Your Name"></sp-textfield>
|
|
26
29
|
`);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
await elementUpdated(el);
|
|
31
|
+
expect(el.tabIndex).to.equal(0);
|
|
32
|
+
el.disabled = true;
|
|
33
|
+
await elementUpdated(el);
|
|
34
|
+
expect(el.tabIndex).to.equal(-1);
|
|
35
|
+
el.tabIndex = 2;
|
|
36
|
+
await elementUpdated(el);
|
|
37
|
+
expect(el.tabIndex).to.equal(-1);
|
|
38
|
+
el.disabled = false;
|
|
39
|
+
await elementUpdated(el);
|
|
40
|
+
expect(el.tabIndex).to.equal(2);
|
|
41
|
+
});
|
|
42
|
+
it("manages tabIndex before first render", async () => {
|
|
43
|
+
const el = document.createElement("sp-textfield");
|
|
44
|
+
expect(el.focusElement).to.be.null;
|
|
45
|
+
expect(el.tabIndex).to.equal(0);
|
|
46
|
+
el.remove();
|
|
47
|
+
});
|
|
48
|
+
it("loads", async () => {
|
|
49
|
+
const testPlaceholder = "Enter your name";
|
|
50
|
+
const el = await litFixture(html`
|
|
48
51
|
<sp-textfield placeholder=${testPlaceholder}></sp-textfield>
|
|
49
52
|
`);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
it('multiline', async () => {
|
|
59
|
-
const el = await litFixture(html `
|
|
53
|
+
expect(el).to.not.equal(void 0);
|
|
54
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
55
|
+
expect(input).to.not.be.null;
|
|
56
|
+
const placeholder = input ? input.placeholder : null;
|
|
57
|
+
expect(placeholder).to.equal(testPlaceholder);
|
|
58
|
+
});
|
|
59
|
+
it("multiline", async () => {
|
|
60
|
+
const el = await litFixture(html`
|
|
60
61
|
<sp-textfield
|
|
61
62
|
placeholder="Enter your name"
|
|
62
63
|
multiline
|
|
63
64
|
></sp-textfield>
|
|
64
65
|
`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
it('resizes by default', async () => {
|
|
72
|
-
const el = await litFixture(html `
|
|
66
|
+
expect(el).to.not.equal(void 0);
|
|
67
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("textarea") : null;
|
|
68
|
+
expect(input).to.not.be.null;
|
|
69
|
+
});
|
|
70
|
+
it("resizes by default", async () => {
|
|
71
|
+
const el = await litFixture(html`
|
|
73
72
|
<sp-textfield
|
|
74
73
|
multiline
|
|
75
74
|
label="No resize control"
|
|
76
75
|
placeholder="No resize control"
|
|
77
76
|
></sp-textfield>
|
|
78
77
|
`);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
const startBounds = el.getBoundingClientRect();
|
|
79
|
+
await sendMouse({
|
|
80
|
+
steps: [
|
|
81
|
+
{
|
|
82
|
+
type: "move",
|
|
83
|
+
position: [startBounds.right - 2, startBounds.bottom - 2]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: "down"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "move",
|
|
90
|
+
position: [startBounds.right + 50, startBounds.bottom + 50]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "up"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
const endBounds = el.getBoundingClientRect();
|
|
98
|
+
expect(endBounds.width).to.be.greaterThan(startBounds.width);
|
|
99
|
+
expect(endBounds.height).to.be.greaterThan(startBounds.height);
|
|
100
|
+
});
|
|
101
|
+
it("accepts resize styling", async () => {
|
|
102
|
+
const el = await litFixture(html`
|
|
104
103
|
<sp-textfield
|
|
105
104
|
multiline
|
|
106
105
|
style="resize: none;"
|
|
@@ -108,45 +107,43 @@ describe('Textfield', () => {
|
|
|
108
107
|
placeholder="No resize control"
|
|
109
108
|
></sp-textfield>
|
|
110
109
|
`);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
const startBounds = el.getBoundingClientRect();
|
|
111
|
+
await sendMouse({
|
|
112
|
+
steps: [
|
|
113
|
+
{
|
|
114
|
+
type: "move",
|
|
115
|
+
position: [startBounds.right - 2, startBounds.bottom - 2]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: "down"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: "move",
|
|
122
|
+
position: [startBounds.right + 50, startBounds.bottom + 50]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: "up"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
const endBounds = el.getBoundingClientRect();
|
|
130
|
+
expect(endBounds.width).equals(startBounds.width);
|
|
131
|
+
expect(endBounds.height).equals(startBounds.height);
|
|
132
|
+
});
|
|
133
|
+
it("grows", async () => {
|
|
134
|
+
const el = await litFixture(html`
|
|
136
135
|
<sp-textfield
|
|
137
136
|
placeholder="Enter your name"
|
|
138
137
|
multiline
|
|
139
138
|
grows
|
|
140
139
|
></sp-textfield>
|
|
141
140
|
`);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
it('valid', async () => {
|
|
149
|
-
const el = await litFixture(html `
|
|
141
|
+
expect(el).to.not.equal(void 0);
|
|
142
|
+
const sizer = el.shadowRoot ? el.shadowRoot.querySelector("#sizer") : null;
|
|
143
|
+
expect(sizer).to.not.be.null;
|
|
144
|
+
});
|
|
145
|
+
it("valid", async () => {
|
|
146
|
+
const el = await litFixture(html`
|
|
150
147
|
<sp-textfield
|
|
151
148
|
placeholder="Enter your number"
|
|
152
149
|
pattern="[\\d]+"
|
|
@@ -154,15 +151,13 @@ describe('Textfield', () => {
|
|
|
154
151
|
required
|
|
155
152
|
></sp-textfield>
|
|
156
153
|
`);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
it('valid - multiline', async () => {
|
|
165
|
-
const el = await litFixture(html `
|
|
154
|
+
await elementUpdated(el);
|
|
155
|
+
expect(el).to.not.equal(void 0);
|
|
156
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
157
|
+
expect(input).to.not.be.null;
|
|
158
|
+
});
|
|
159
|
+
it("valid - multiline", async () => {
|
|
160
|
+
const el = await litFixture(html`
|
|
166
161
|
<sp-textfield
|
|
167
162
|
placeholder="Enter your number"
|
|
168
163
|
pattern="[\\d]+"
|
|
@@ -171,30 +166,26 @@ describe('Textfield', () => {
|
|
|
171
166
|
multiline
|
|
172
167
|
></sp-textfield>
|
|
173
168
|
`);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
it('valid - required', async () => {
|
|
182
|
-
const el = await litFixture(html `
|
|
169
|
+
await elementUpdated(el);
|
|
170
|
+
expect(el).to.not.equal(void 0);
|
|
171
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
172
|
+
expect(input).to.not.be.null;
|
|
173
|
+
});
|
|
174
|
+
it("valid - required", async () => {
|
|
175
|
+
const el = await litFixture(html`
|
|
183
176
|
<sp-textfield
|
|
184
177
|
placeholder="Enter your number"
|
|
185
178
|
value="123"
|
|
186
179
|
required
|
|
187
180
|
></sp-textfield>
|
|
188
181
|
`);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
it('valid - multiline - required', async () => {
|
|
197
|
-
const el = await litFixture(html `
|
|
182
|
+
await elementUpdated(el);
|
|
183
|
+
expect(el).to.not.equal(void 0);
|
|
184
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
185
|
+
expect(input).to.not.be.null;
|
|
186
|
+
});
|
|
187
|
+
it("valid - multiline - required", async () => {
|
|
188
|
+
const el = await litFixture(html`
|
|
198
189
|
<sp-textfield
|
|
199
190
|
placeholder="Enter your number"
|
|
200
191
|
value="123"
|
|
@@ -202,15 +193,13 @@ describe('Textfield', () => {
|
|
|
202
193
|
multiline
|
|
203
194
|
></sp-textfield>
|
|
204
195
|
`);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
it('valid - boundary-type assertions', async () => {
|
|
213
|
-
const el = await litFixture(html `
|
|
196
|
+
await elementUpdated(el);
|
|
197
|
+
expect(el).to.not.equal(void 0);
|
|
198
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
199
|
+
expect(input).to.not.be.null;
|
|
200
|
+
});
|
|
201
|
+
it("valid - boundary-type assertions", async () => {
|
|
202
|
+
const el = await litFixture(html`
|
|
214
203
|
<sp-textfield
|
|
215
204
|
placeholder="Enter your number"
|
|
216
205
|
pattern="^[\\d]+$"
|
|
@@ -218,15 +207,13 @@ describe('Textfield', () => {
|
|
|
218
207
|
required
|
|
219
208
|
></sp-textfield>
|
|
220
209
|
`);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
it('valid - multiline - boundary-type assertions', async () => {
|
|
229
|
-
const el = await litFixture(html `
|
|
210
|
+
await elementUpdated(el);
|
|
211
|
+
expect(el).to.not.equal(void 0);
|
|
212
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
213
|
+
expect(input).to.not.be.null;
|
|
214
|
+
});
|
|
215
|
+
it("valid - multiline - boundary-type assertions", async () => {
|
|
216
|
+
const el = await litFixture(html`
|
|
230
217
|
<sp-textfield
|
|
231
218
|
placeholder="Enter your number"
|
|
232
219
|
pattern="^[\\d]+$"
|
|
@@ -235,15 +222,13 @@ describe('Textfield', () => {
|
|
|
235
222
|
multiline
|
|
236
223
|
></sp-textfield>
|
|
237
224
|
`);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
it('valid - unicode', async () => {
|
|
246
|
-
const el = await litFixture(html `
|
|
225
|
+
await elementUpdated(el);
|
|
226
|
+
expect(el).to.not.equal(void 0);
|
|
227
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
228
|
+
expect(input).to.not.be.null;
|
|
229
|
+
});
|
|
230
|
+
it("valid - unicode", async () => {
|
|
231
|
+
const el = await litFixture(html`
|
|
247
232
|
<sp-textfield
|
|
248
233
|
placeholder="Enter your name"
|
|
249
234
|
pattern="\\p{L}{4,8}"
|
|
@@ -251,15 +236,13 @@ describe('Textfield', () => {
|
|
|
251
236
|
required
|
|
252
237
|
></sp-textfield>
|
|
253
238
|
`);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
it('valid - multiline - unicode', async () => {
|
|
262
|
-
const el = await litFixture(html `
|
|
239
|
+
await elementUpdated(el);
|
|
240
|
+
expect(el).to.not.equal(void 0);
|
|
241
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
242
|
+
expect(input).to.not.be.null;
|
|
243
|
+
});
|
|
244
|
+
it("valid - multiline - unicode", async () => {
|
|
245
|
+
const el = await litFixture(html`
|
|
263
246
|
<sp-textfield
|
|
264
247
|
placeholder="Enter your name"
|
|
265
248
|
pattern="\\p{L}{4,8}"
|
|
@@ -268,15 +251,13 @@ describe('Textfield', () => {
|
|
|
268
251
|
multiline
|
|
269
252
|
></sp-textfield>
|
|
270
253
|
`);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
it('invalid', async () => {
|
|
279
|
-
const el = await litFixture(html `
|
|
254
|
+
await elementUpdated(el);
|
|
255
|
+
expect(el).to.not.equal(void 0);
|
|
256
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
257
|
+
expect(input).to.not.be.null;
|
|
258
|
+
});
|
|
259
|
+
it("invalid", async () => {
|
|
260
|
+
const el = await litFixture(html`
|
|
280
261
|
<sp-textfield
|
|
281
262
|
placeholder="Enter your number"
|
|
282
263
|
pattern="[\\d]+"
|
|
@@ -284,15 +265,13 @@ describe('Textfield', () => {
|
|
|
284
265
|
required
|
|
285
266
|
></sp-textfield>
|
|
286
267
|
`);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
it('invalid - multiline', async () => {
|
|
295
|
-
const el = await litFixture(html `
|
|
268
|
+
await elementUpdated(el);
|
|
269
|
+
expect(el).to.not.equal(void 0);
|
|
270
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
271
|
+
expect(input).to.not.be.null;
|
|
272
|
+
});
|
|
273
|
+
it("invalid - multiline", async () => {
|
|
274
|
+
const el = await litFixture(html`
|
|
296
275
|
<sp-textfield
|
|
297
276
|
placeholder="Enter your number"
|
|
298
277
|
pattern="[\\d]+"
|
|
@@ -301,30 +280,26 @@ describe('Textfield', () => {
|
|
|
301
280
|
multiline
|
|
302
281
|
></sp-textfield>
|
|
303
282
|
`);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
it('invalid - required', async () => {
|
|
312
|
-
const el = await litFixture(html `
|
|
283
|
+
await elementUpdated(el);
|
|
284
|
+
expect(el).to.not.equal(void 0);
|
|
285
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
286
|
+
expect(input).to.not.be.null;
|
|
287
|
+
});
|
|
288
|
+
it("invalid - required", async () => {
|
|
289
|
+
const el = await litFixture(html`
|
|
313
290
|
<sp-textfield
|
|
314
291
|
placeholder="Enter your number"
|
|
315
292
|
value=""
|
|
316
293
|
required
|
|
317
294
|
></sp-textfield>
|
|
318
295
|
`);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
it('invalid - multiline - required', async () => {
|
|
327
|
-
const el = await litFixture(html `
|
|
296
|
+
await elementUpdated(el);
|
|
297
|
+
expect(el).to.not.equal(void 0);
|
|
298
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
299
|
+
expect(input).to.not.be.null;
|
|
300
|
+
});
|
|
301
|
+
it("invalid - multiline - required", async () => {
|
|
302
|
+
const el = await litFixture(html`
|
|
328
303
|
<sp-textfield
|
|
329
304
|
placeholder="Enter your number"
|
|
330
305
|
value=""
|
|
@@ -332,15 +307,13 @@ describe('Textfield', () => {
|
|
|
332
307
|
multiline
|
|
333
308
|
></sp-textfield>
|
|
334
309
|
`);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
it('invalid - unicode', async () => {
|
|
343
|
-
const el = await litFixture(html `
|
|
310
|
+
await elementUpdated(el);
|
|
311
|
+
expect(el).to.not.equal(void 0);
|
|
312
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
313
|
+
expect(input).to.not.be.null;
|
|
314
|
+
});
|
|
315
|
+
it("invalid - unicode", async () => {
|
|
316
|
+
const el = await litFixture(html`
|
|
344
317
|
<sp-textfield
|
|
345
318
|
placeholder="Enter your number"
|
|
346
319
|
pattern="\\p{N}+"
|
|
@@ -348,15 +321,13 @@ describe('Textfield', () => {
|
|
|
348
321
|
required
|
|
349
322
|
></sp-textfield>
|
|
350
323
|
`);
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
it('invalid - multiline - unicode', async () => {
|
|
359
|
-
const el = await litFixture(html `
|
|
324
|
+
await elementUpdated(el);
|
|
325
|
+
expect(el).to.not.equal(void 0);
|
|
326
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
327
|
+
expect(input).to.not.be.null;
|
|
328
|
+
});
|
|
329
|
+
it("invalid - multiline - unicode", async () => {
|
|
330
|
+
const el = await litFixture(html`
|
|
360
331
|
<sp-textfield
|
|
361
332
|
placeholder="Enter your number"
|
|
362
333
|
pattern="\\p{N}+"
|
|
@@ -365,15 +336,13 @@ describe('Textfield', () => {
|
|
|
365
336
|
multiline
|
|
366
337
|
></sp-textfield>
|
|
367
338
|
`);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
it('invalid - boundary-type assertions', async () => {
|
|
376
|
-
const el = await litFixture(html `
|
|
339
|
+
await elementUpdated(el);
|
|
340
|
+
expect(el).to.not.equal(void 0);
|
|
341
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
342
|
+
expect(input).to.not.be.null;
|
|
343
|
+
});
|
|
344
|
+
it("invalid - boundary-type assertions", async () => {
|
|
345
|
+
const el = await litFixture(html`
|
|
377
346
|
<sp-textfield
|
|
378
347
|
placeholder="Enter your number"
|
|
379
348
|
pattern="^\\p{N}+$"
|
|
@@ -381,15 +350,13 @@ describe('Textfield', () => {
|
|
|
381
350
|
required
|
|
382
351
|
></sp-textfield>
|
|
383
352
|
`);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
it('invalid - multiline - boundary-type assertions', async () => {
|
|
392
|
-
const el = await litFixture(html `
|
|
353
|
+
await elementUpdated(el);
|
|
354
|
+
expect(el).to.not.equal(void 0);
|
|
355
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
356
|
+
expect(input).to.not.be.null;
|
|
357
|
+
});
|
|
358
|
+
it("invalid - multiline - boundary-type assertions", async () => {
|
|
359
|
+
const el = await litFixture(html`
|
|
393
360
|
<sp-textfield
|
|
394
361
|
placeholder="Enter your number"
|
|
395
362
|
pattern="^\\p{N}+$"
|
|
@@ -398,90 +365,88 @@ describe('Textfield', () => {
|
|
|
398
365
|
multiline
|
|
399
366
|
></sp-textfield>
|
|
400
367
|
`);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
document.addEventListener('focusin', onFocusIn);
|
|
415
|
-
const el = await litFixture(html `
|
|
368
|
+
await elementUpdated(el);
|
|
369
|
+
expect(el).to.not.equal(void 0);
|
|
370
|
+
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
371
|
+
expect(input).to.not.be.null;
|
|
372
|
+
});
|
|
373
|
+
it("receives focus", async () => {
|
|
374
|
+
let activeElement = null;
|
|
375
|
+
const onFocusIn = (event) => {
|
|
376
|
+
const path = event.composedPath();
|
|
377
|
+
activeElement = path[0];
|
|
378
|
+
};
|
|
379
|
+
document.addEventListener("focusin", onFocusIn);
|
|
380
|
+
const el = await litFixture(html`
|
|
416
381
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
417
382
|
`);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
383
|
+
await elementUpdated(el);
|
|
384
|
+
el.focus();
|
|
385
|
+
await elementUpdated(el);
|
|
386
|
+
expect(activeElement === el.focusElement).to.be.true;
|
|
387
|
+
document.removeEventListener("focusin", onFocusIn);
|
|
388
|
+
});
|
|
389
|
+
it("does not receive focus when disabled", async () => {
|
|
390
|
+
let activeElement = null;
|
|
391
|
+
const onFocusIn = (event) => {
|
|
392
|
+
const path = event.composedPath();
|
|
393
|
+
activeElement = path[0];
|
|
394
|
+
};
|
|
395
|
+
document.addEventListener("focusin", onFocusIn);
|
|
396
|
+
const el = await litFixture(html`
|
|
432
397
|
<sp-textfield
|
|
433
398
|
disabled
|
|
434
399
|
placeholder="Enter your name"
|
|
435
400
|
></sp-textfield>
|
|
436
401
|
`);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
402
|
+
await elementUpdated(el);
|
|
403
|
+
el.focus();
|
|
404
|
+
await elementUpdated(el);
|
|
405
|
+
expect(activeElement === el.focusElement).to.be.false;
|
|
406
|
+
expect(document.activeElement === el).to.be.false;
|
|
407
|
+
document.removeEventListener("focusin", onFocusIn);
|
|
408
|
+
el.click();
|
|
409
|
+
await elementUpdated(el);
|
|
410
|
+
expect(activeElement === el.focusElement).to.be.false;
|
|
411
|
+
expect(document.activeElement === el).to.be.false;
|
|
412
|
+
document.removeEventListener("focusin", onFocusIn);
|
|
413
|
+
});
|
|
414
|
+
it("accepts input", async () => {
|
|
415
|
+
const testValue = "Test Name";
|
|
416
|
+
const el = await litFixture(html`
|
|
452
417
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
453
418
|
`);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
419
|
+
await elementUpdated(el);
|
|
420
|
+
el.focusElement.value = testValue;
|
|
421
|
+
el.focusElement.dispatchEvent(new Event("input"));
|
|
422
|
+
expect(el.value).to.equal(testValue);
|
|
423
|
+
});
|
|
424
|
+
it("selects", async () => {
|
|
425
|
+
const testValue = "Test Name";
|
|
426
|
+
const el = await litFixture(html`
|
|
462
427
|
<sp-textfield value=${testValue}></sp-textfield>
|
|
463
428
|
`);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
429
|
+
await elementUpdated(el);
|
|
430
|
+
expect(el.value).to.equal(testValue);
|
|
431
|
+
el.focus();
|
|
432
|
+
el.select();
|
|
433
|
+
await sendKeys({ press: "Backspace" });
|
|
434
|
+
expect(el.value).to.equal("");
|
|
435
|
+
});
|
|
436
|
+
it("setSelectionRange", async () => {
|
|
437
|
+
const testValue = "Test Name";
|
|
438
|
+
const el = await litFixture(html`
|
|
474
439
|
<sp-textfield value=${testValue}></sp-textfield>
|
|
475
440
|
`);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
441
|
+
await elementUpdated(el);
|
|
442
|
+
expect(el.value).to.equal(testValue);
|
|
443
|
+
el.focus();
|
|
444
|
+
el.setSelectionRange(0, "Test ".length);
|
|
445
|
+
await sendKeys({ press: "Backspace" });
|
|
446
|
+
expect(el.value).to.equal("Name");
|
|
447
|
+
});
|
|
448
|
+
it("accepts maxlength", async () => {
|
|
449
|
+
const el = await litFixture(html`
|
|
485
450
|
<sp-textfield
|
|
486
451
|
placeholder="Enter your name"
|
|
487
452
|
maxlength="3"
|
|
@@ -489,211 +454,194 @@ describe('Textfield', () => {
|
|
|
489
454
|
required
|
|
490
455
|
></sp-textfield>
|
|
491
456
|
`);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
457
|
+
await elementUpdated(el);
|
|
458
|
+
el.focus();
|
|
459
|
+
await sendKeys({
|
|
460
|
+
type: "a"
|
|
461
|
+
});
|
|
462
|
+
await elementUpdated(el);
|
|
463
|
+
expect(el.value).to.equal("a");
|
|
464
|
+
expect(el.checkValidity()).to.be.false;
|
|
465
|
+
await sendKeys({
|
|
466
|
+
type: "b"
|
|
467
|
+
});
|
|
468
|
+
await elementUpdated(el);
|
|
469
|
+
expect(el.value).to.equal("ab");
|
|
470
|
+
expect(el.checkValidity());
|
|
471
|
+
await sendKeys({
|
|
472
|
+
type: "c"
|
|
473
|
+
});
|
|
474
|
+
await elementUpdated(el);
|
|
475
|
+
expect(el.value).to.equal("abc");
|
|
476
|
+
expect(el.checkValidity());
|
|
477
|
+
await sendKeys({
|
|
478
|
+
type: "d"
|
|
479
|
+
});
|
|
480
|
+
await elementUpdated(el);
|
|
481
|
+
expect(el.value).to.equal("abc");
|
|
482
|
+
expect(el.checkValidity());
|
|
483
|
+
await sendKeys({
|
|
484
|
+
press: "Backspace"
|
|
485
|
+
});
|
|
486
|
+
await elementUpdated(el);
|
|
487
|
+
expect(el.value).to.equal("ab");
|
|
488
|
+
expect(el.checkValidity());
|
|
489
|
+
await sendKeys({
|
|
490
|
+
press: "Backspace"
|
|
491
|
+
});
|
|
492
|
+
await elementUpdated(el);
|
|
493
|
+
expect(el.value).to.equal("a");
|
|
494
|
+
expect(el.checkValidity()).to.be.false;
|
|
495
|
+
});
|
|
496
|
+
it("dispatches a `change` event", async () => {
|
|
497
|
+
const testValue = "Test Name";
|
|
498
|
+
let eventSource = null;
|
|
499
|
+
const onChange = (event) => {
|
|
500
|
+
eventSource = event.composedPath()[0];
|
|
501
|
+
};
|
|
502
|
+
const el = await litFixture(html`
|
|
538
503
|
<sp-textfield
|
|
539
504
|
placeholder="Enter your name"
|
|
540
505
|
@change=${onChange}
|
|
541
506
|
></sp-textfield>
|
|
542
507
|
`);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
508
|
+
await elementUpdated(el);
|
|
509
|
+
el.focusElement.value = testValue;
|
|
510
|
+
el.focusElement.dispatchEvent(new Event("input"));
|
|
511
|
+
el.focusElement.dispatchEvent(new Event("change"));
|
|
512
|
+
expect(el.value).to.equal(testValue);
|
|
513
|
+
const testSource = eventSource;
|
|
514
|
+
expect(testSource).to.equal(el);
|
|
515
|
+
});
|
|
516
|
+
it("passes through `autocomplete` attribute", async () => {
|
|
517
|
+
let el = await litFixture(html`
|
|
553
518
|
<sp-textfield autocomplete="off"></sp-textfield>
|
|
554
519
|
`);
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
520
|
+
await elementUpdated(el);
|
|
521
|
+
let input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
522
|
+
expect(input).to.exist;
|
|
523
|
+
if (input) {
|
|
524
|
+
expect(input.getAttribute("autocomplete")).to.equal("off");
|
|
525
|
+
}
|
|
526
|
+
el = await litFixture(html`
|
|
562
527
|
<sp-textfield></sp-textfield>
|
|
563
528
|
`);
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
529
|
+
await elementUpdated(el);
|
|
530
|
+
input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
531
|
+
expect(input).to.exist;
|
|
532
|
+
if (input) {
|
|
533
|
+
expect(input.getAttribute("autocomplete")).to.not.exist;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
it("tests on `required` changes", async () => {
|
|
537
|
+
const el = await litFixture(html`
|
|
573
538
|
<sp-textfield value=""></sp-textfield>
|
|
574
539
|
`);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
540
|
+
await elementUpdated(el);
|
|
541
|
+
expect(el.invalid).to.be.false;
|
|
542
|
+
el.required = true;
|
|
543
|
+
await elementUpdated(el);
|
|
544
|
+
expect(el.invalid).to.be.true;
|
|
545
|
+
});
|
|
546
|
+
it("manages `allowed-keys`", async () => {
|
|
547
|
+
const el = await litFixture(html`
|
|
583
548
|
<sp-textfield allowed-keys="asdf"></sp-textfield>
|
|
584
549
|
`);
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
'email',
|
|
617
|
-
'password',
|
|
618
|
-
];
|
|
619
|
-
try {
|
|
620
|
-
for (var types_1 = __asyncValues(types), types_1_1; types_1_1 = await types_1.next(), !types_1_1.done;) {
|
|
621
|
-
const t = types_1_1.value;
|
|
622
|
-
const el = await litFixture(html `
|
|
550
|
+
await elementUpdated(el);
|
|
551
|
+
expect(el.value).to.equal("");
|
|
552
|
+
const inputElement = el.focusElement;
|
|
553
|
+
el.focusElement.value = "asdf";
|
|
554
|
+
inputElement.dispatchEvent(new InputEvent("input"));
|
|
555
|
+
await elementUpdated(el);
|
|
556
|
+
expect(el.value).to.equal("asdf");
|
|
557
|
+
inputElement.value = `asdff`;
|
|
558
|
+
inputElement.setSelectionRange(1, 1);
|
|
559
|
+
inputElement.dispatchEvent(new InputEvent("input"));
|
|
560
|
+
await elementUpdated(el);
|
|
561
|
+
expect(el.value).to.equal("asdff");
|
|
562
|
+
expect(inputElement.selectionStart).to.equal(1);
|
|
563
|
+
inputElement.value = `asdoff`;
|
|
564
|
+
inputElement.setSelectionRange(4, 4);
|
|
565
|
+
inputElement.dispatchEvent(new InputEvent("input"));
|
|
566
|
+
await elementUpdated(el);
|
|
567
|
+
expect(el.value).to.equal("asdff");
|
|
568
|
+
expect(inputElement.selectionStart).to.equal(3);
|
|
569
|
+
});
|
|
570
|
+
describe("type attribute", () => {
|
|
571
|
+
it("assigns valid attributes to the property", async () => {
|
|
572
|
+
const types = [
|
|
573
|
+
"text",
|
|
574
|
+
"url",
|
|
575
|
+
"tel",
|
|
576
|
+
"email",
|
|
577
|
+
"password"
|
|
578
|
+
];
|
|
579
|
+
for await (const t of types) {
|
|
580
|
+
const el = await litFixture(html`
|
|
623
581
|
<sp-textfield type=${t}></sp-textfield>
|
|
624
582
|
`);
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
try {
|
|
633
|
-
if (types_1_1 && !types_1_1.done && (_a = types_1.return)) await _a.call(types_1);
|
|
634
|
-
}
|
|
635
|
-
finally { if (e_1) throw e_1.error; }
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
it('represents invalid and missing attributes as "text"', async () => {
|
|
639
|
-
const el1 = await litFixture(html `
|
|
583
|
+
expect(el.type).equals(t);
|
|
584
|
+
el.setAttribute("type", "url");
|
|
585
|
+
expect(el.type).equals("url");
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
it('represents invalid and missing attributes as "text"', async () => {
|
|
589
|
+
const el1 = await litFixture(html`
|
|
640
590
|
<sp-textfield></sp-textfield>
|
|
641
591
|
`);
|
|
642
|
-
|
|
592
|
+
const el2 = await litFixture(html`
|
|
643
593
|
<sp-textfield type="time"></sp-textfield>
|
|
644
594
|
`);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
595
|
+
expect(el1.type).equals("text");
|
|
596
|
+
expect(el2.type).equals("text");
|
|
597
|
+
el1.setAttribute("type", "submit");
|
|
598
|
+
expect(el1.type).equals("text");
|
|
599
|
+
});
|
|
600
|
+
it("reflects valid property assignments", async () => {
|
|
601
|
+
const el = await litFixture(html`
|
|
652
602
|
<sp-textfield type="url"></sp-textfield>
|
|
653
603
|
`);
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
604
|
+
el.type = "email";
|
|
605
|
+
await elementUpdated(el);
|
|
606
|
+
expect(el.getAttribute("type")).equals("email");
|
|
607
|
+
expect(el.type).equals("email");
|
|
608
|
+
});
|
|
609
|
+
it('reflects invalid assignments but sets state to "text"', async () => {
|
|
610
|
+
const el = await litFixture(html`
|
|
661
611
|
<sp-textfield type="url"></sp-textfield>
|
|
662
612
|
`);
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
it('accepts help text in `slot="help-text"`', async () => {
|
|
676
|
-
const el = await litFixture(html `
|
|
613
|
+
el.type = "range";
|
|
614
|
+
await elementUpdated(el);
|
|
615
|
+
expect(el.getAttribute("type")).equals("range");
|
|
616
|
+
expect(el.type).equals("text");
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
describe("help text", () => {
|
|
620
|
+
const name = "This is a textfield";
|
|
621
|
+
const description = "This text helps you fill it out";
|
|
622
|
+
const descriptionNegative = "This text helps you when invalid";
|
|
623
|
+
it('accepts help text in `slot="help-text"`', async () => {
|
|
624
|
+
const el = await litFixture(html`
|
|
677
625
|
<sp-textfield label=${name}>
|
|
678
626
|
<sp-help-text slot="help-text">${description}</sp-help-text>
|
|
679
627
|
</sp-textfield>
|
|
680
628
|
`);
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
629
|
+
await elementUpdated(el);
|
|
630
|
+
await findDescribedNode(name, description);
|
|
631
|
+
});
|
|
632
|
+
it('accepts help text in `slot="help-text"` w/ own ID', async () => {
|
|
633
|
+
const el = await litFixture(html`
|
|
686
634
|
<sp-textfield label=${name}>
|
|
687
635
|
<sp-help-text slot="help-text" id="help-text-id-1">
|
|
688
636
|
${description}
|
|
689
637
|
</sp-help-text>
|
|
690
638
|
</sp-textfield>
|
|
691
639
|
`);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
640
|
+
await elementUpdated(el);
|
|
641
|
+
await findDescribedNode(name, description);
|
|
642
|
+
});
|
|
643
|
+
it("manages neutral/negative help text pairs", async () => {
|
|
644
|
+
const el = await litFixture(html`
|
|
697
645
|
<sp-textfield label=${name}>
|
|
698
646
|
<sp-help-text slot="help-text">${description}</sp-help-text>
|
|
699
647
|
<sp-help-text slot="negative-help-text">
|
|
@@ -701,17 +649,17 @@ describe('Textfield', () => {
|
|
|
701
649
|
</sp-help-text>
|
|
702
650
|
</sp-textfield>
|
|
703
651
|
`);
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
652
|
+
const negativeHelpText = el.querySelector('[slot="negative-help-text"]');
|
|
653
|
+
await elementUpdated(el);
|
|
654
|
+
expect(negativeHelpText.variant).to.equal("neutral");
|
|
655
|
+
await findDescribedNode(name, description);
|
|
656
|
+
el.invalid = true;
|
|
657
|
+
await elementUpdated(el);
|
|
658
|
+
expect(negativeHelpText.variant).to.equal("negative");
|
|
659
|
+
await findDescribedNode(name, descriptionNegative);
|
|
660
|
+
});
|
|
661
|
+
it("manages neutral/negative help text pairs w/ own IDs", async () => {
|
|
662
|
+
const el = await litFixture(html`
|
|
715
663
|
<sp-textfield label=${name}>
|
|
716
664
|
<sp-help-text slot="help-text" id="help-text-id-2">
|
|
717
665
|
${description}
|
|
@@ -721,15 +669,15 @@ describe('Textfield', () => {
|
|
|
721
669
|
</sp-help-text>
|
|
722
670
|
</sp-textfield>
|
|
723
671
|
`);
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
});
|
|
672
|
+
const negativeHelpText = el.querySelector('[slot="negative-help-text"]');
|
|
673
|
+
await elementUpdated(el);
|
|
674
|
+
expect(negativeHelpText.variant).to.equal("neutral");
|
|
675
|
+
await findDescribedNode(name, description);
|
|
676
|
+
el.invalid = true;
|
|
677
|
+
await elementUpdated(el);
|
|
678
|
+
expect(negativeHelpText.variant).to.equal("negative");
|
|
679
|
+
await findDescribedNode(name, descriptionNegative);
|
|
733
680
|
});
|
|
681
|
+
});
|
|
734
682
|
});
|
|
735
|
-
//# sourceMappingURL=textfield.test.js.map
|
|
683
|
+
//# sourceMappingURL=textfield.test.js.map
|