@spectrum-web-components/textfield 0.12.1-devmode2.0 → 0.13.1
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/package.json +8 -8
- package/sp-textfield.dev.js +1 -0
- package/sp-textfield.dev.js.map +1 -1
- package/sp-textfield.js +1 -2
- package/sp-textfield.js.map +2 -2
- package/src/Textfield.dev.js +28 -10
- package/src/Textfield.dev.js.map +1 -1
- package/src/Textfield.js +23 -253
- package/src/Textfield.js.map +2 -2
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-textfield.css.dev.js +1 -0
- package/src/spectrum-textfield.css.dev.js.map +1 -1
- package/src/spectrum-textfield.css.js +2 -4
- package/src/spectrum-textfield.css.js.map +2 -2
- package/src/textfield.css.dev.js +2 -1
- package/src/textfield.css.dev.js.map +2 -2
- package/src/textfield.css.js +3 -5
- package/src/textfield.css.js.map +3 -3
- package/stories/textarea.stories.js +1 -0
- package/stories/textarea.stories.js.map +1 -1
- package/stories/textfield.stories.js +1 -0
- package/stories/textfield.stories.js.map +1 -1
- package/test/benchmark/test-basic.js +1 -0
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/textarea.test-vrt.js +1 -0
- package/test/textarea.test-vrt.js.map +1 -1
- package/test/textfield.test-vrt.js +1 -0
- package/test/textfield.test-vrt.js.map +1 -1
- package/test/textfield.test.js +173 -84
- package/test/textfield.test.js.map +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["textarea.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/textarea.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('TextareaStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,mBAAmB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["textfield.test-vrt.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/textfield.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('TextfieldStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAE/B,eAAe,oBAAoB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/textfield.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { elementUpdated, expect, html, litFixture } from "@open-wc/testing";
|
|
2
3
|
import { sendKeys } from "@web/test-runner-commands";
|
|
3
4
|
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
@@ -6,27 +7,37 @@ import "@spectrum-web-components/help-text/sp-help-text.js";
|
|
|
6
7
|
import "@spectrum-web-components/textfield/sp-textfield.js";
|
|
7
8
|
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
8
9
|
describe("Textfield", () => {
|
|
9
|
-
testForLitDevWarnings(
|
|
10
|
+
testForLitDevWarnings(
|
|
11
|
+
async () => await litFixture(
|
|
12
|
+
html`
|
|
10
13
|
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
11
|
-
`
|
|
14
|
+
`
|
|
15
|
+
)
|
|
16
|
+
);
|
|
12
17
|
it("loads default textfield accessibly", async () => {
|
|
13
|
-
const el = await litFixture(
|
|
18
|
+
const el = await litFixture(
|
|
19
|
+
html`
|
|
14
20
|
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
15
|
-
`
|
|
21
|
+
`
|
|
22
|
+
);
|
|
16
23
|
await elementUpdated(el);
|
|
17
24
|
await expect(el).to.be.accessible();
|
|
18
25
|
});
|
|
19
26
|
it("loads multiline textfield accessibly", async () => {
|
|
20
|
-
const el = await litFixture(
|
|
27
|
+
const el = await litFixture(
|
|
28
|
+
html`
|
|
21
29
|
<sp-textfield label="Enter your name" multiline></sp-textfield>
|
|
22
|
-
`
|
|
30
|
+
`
|
|
31
|
+
);
|
|
23
32
|
await elementUpdated(el);
|
|
24
33
|
await expect(el).to.be.accessible();
|
|
25
34
|
});
|
|
26
35
|
it("manages tabIndex while disabled", async () => {
|
|
27
|
-
const el = await litFixture(
|
|
36
|
+
const el = await litFixture(
|
|
37
|
+
html`
|
|
28
38
|
<sp-textfield placeholder="Enter Your Name"></sp-textfield>
|
|
29
|
-
`
|
|
39
|
+
`
|
|
40
|
+
);
|
|
30
41
|
await elementUpdated(el);
|
|
31
42
|
expect(el.tabIndex).to.equal(0);
|
|
32
43
|
el.disabled = true;
|
|
@@ -47,9 +58,11 @@ describe("Textfield", () => {
|
|
|
47
58
|
});
|
|
48
59
|
it("loads", async () => {
|
|
49
60
|
const testPlaceholder = "Enter your name";
|
|
50
|
-
const el = await litFixture(
|
|
61
|
+
const el = await litFixture(
|
|
62
|
+
html`
|
|
51
63
|
<sp-textfield placeholder=${testPlaceholder}></sp-textfield>
|
|
52
|
-
`
|
|
64
|
+
`
|
|
65
|
+
);
|
|
53
66
|
expect(el).to.not.equal(void 0);
|
|
54
67
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
55
68
|
expect(input).to.not.be.null;
|
|
@@ -57,24 +70,28 @@ describe("Textfield", () => {
|
|
|
57
70
|
expect(placeholder).to.equal(testPlaceholder);
|
|
58
71
|
});
|
|
59
72
|
it("multiline", async () => {
|
|
60
|
-
const el = await litFixture(
|
|
73
|
+
const el = await litFixture(
|
|
74
|
+
html`
|
|
61
75
|
<sp-textfield
|
|
62
76
|
placeholder="Enter your name"
|
|
63
77
|
multiline
|
|
64
78
|
></sp-textfield>
|
|
65
|
-
`
|
|
79
|
+
`
|
|
80
|
+
);
|
|
66
81
|
expect(el).to.not.equal(void 0);
|
|
67
82
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("textarea") : null;
|
|
68
83
|
expect(input).to.not.be.null;
|
|
69
84
|
});
|
|
70
85
|
it("resizes by default", async () => {
|
|
71
|
-
const el = await litFixture(
|
|
86
|
+
const el = await litFixture(
|
|
87
|
+
html`
|
|
72
88
|
<sp-textfield
|
|
73
89
|
multiline
|
|
74
90
|
label="No resize control"
|
|
75
91
|
placeholder="No resize control"
|
|
76
92
|
></sp-textfield>
|
|
77
|
-
`
|
|
93
|
+
`
|
|
94
|
+
);
|
|
78
95
|
const startBounds = el.getBoundingClientRect();
|
|
79
96
|
await sendMouse({
|
|
80
97
|
steps: [
|
|
@@ -99,14 +116,16 @@ describe("Textfield", () => {
|
|
|
99
116
|
expect(endBounds.height).to.be.greaterThan(startBounds.height);
|
|
100
117
|
});
|
|
101
118
|
it("accepts resize styling", async () => {
|
|
102
|
-
const el = await litFixture(
|
|
119
|
+
const el = await litFixture(
|
|
120
|
+
html`
|
|
103
121
|
<sp-textfield
|
|
104
122
|
multiline
|
|
105
123
|
style="resize: none;"
|
|
106
124
|
label="No resize control"
|
|
107
125
|
placeholder="No resize control"
|
|
108
126
|
></sp-textfield>
|
|
109
|
-
`
|
|
127
|
+
`
|
|
128
|
+
);
|
|
110
129
|
const startBounds = el.getBoundingClientRect();
|
|
111
130
|
await sendMouse({
|
|
112
131
|
steps: [
|
|
@@ -131,33 +150,38 @@ describe("Textfield", () => {
|
|
|
131
150
|
expect(endBounds.height).equals(startBounds.height);
|
|
132
151
|
});
|
|
133
152
|
it("grows", async () => {
|
|
134
|
-
const el = await litFixture(
|
|
153
|
+
const el = await litFixture(
|
|
154
|
+
html`
|
|
135
155
|
<sp-textfield
|
|
136
156
|
placeholder="Enter your name"
|
|
137
157
|
multiline
|
|
138
158
|
grows
|
|
139
159
|
></sp-textfield>
|
|
140
|
-
`
|
|
160
|
+
`
|
|
161
|
+
);
|
|
141
162
|
expect(el).to.not.equal(void 0);
|
|
142
163
|
const sizer = el.shadowRoot ? el.shadowRoot.querySelector("#sizer") : null;
|
|
143
164
|
expect(sizer).to.not.be.null;
|
|
144
165
|
});
|
|
145
166
|
it("valid", async () => {
|
|
146
|
-
const el = await litFixture(
|
|
167
|
+
const el = await litFixture(
|
|
168
|
+
html`
|
|
147
169
|
<sp-textfield
|
|
148
170
|
placeholder="Enter your number"
|
|
149
171
|
pattern="[\\d]+"
|
|
150
172
|
value="123"
|
|
151
173
|
required
|
|
152
174
|
></sp-textfield>
|
|
153
|
-
`
|
|
175
|
+
`
|
|
176
|
+
);
|
|
154
177
|
await elementUpdated(el);
|
|
155
178
|
expect(el).to.not.equal(void 0);
|
|
156
179
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
157
180
|
expect(input).to.not.be.null;
|
|
158
181
|
});
|
|
159
182
|
it("valid - multiline", async () => {
|
|
160
|
-
const el = await litFixture(
|
|
183
|
+
const el = await litFixture(
|
|
184
|
+
html`
|
|
161
185
|
<sp-textfield
|
|
162
186
|
placeholder="Enter your number"
|
|
163
187
|
pattern="[\\d]+"
|
|
@@ -165,55 +189,63 @@ describe("Textfield", () => {
|
|
|
165
189
|
required
|
|
166
190
|
multiline
|
|
167
191
|
></sp-textfield>
|
|
168
|
-
`
|
|
192
|
+
`
|
|
193
|
+
);
|
|
169
194
|
await elementUpdated(el);
|
|
170
195
|
expect(el).to.not.equal(void 0);
|
|
171
196
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
172
197
|
expect(input).to.not.be.null;
|
|
173
198
|
});
|
|
174
199
|
it("valid - required", async () => {
|
|
175
|
-
const el = await litFixture(
|
|
200
|
+
const el = await litFixture(
|
|
201
|
+
html`
|
|
176
202
|
<sp-textfield
|
|
177
203
|
placeholder="Enter your number"
|
|
178
204
|
value="123"
|
|
179
205
|
required
|
|
180
206
|
></sp-textfield>
|
|
181
|
-
`
|
|
207
|
+
`
|
|
208
|
+
);
|
|
182
209
|
await elementUpdated(el);
|
|
183
210
|
expect(el).to.not.equal(void 0);
|
|
184
211
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
185
212
|
expect(input).to.not.be.null;
|
|
186
213
|
});
|
|
187
214
|
it("valid - multiline - required", async () => {
|
|
188
|
-
const el = await litFixture(
|
|
215
|
+
const el = await litFixture(
|
|
216
|
+
html`
|
|
189
217
|
<sp-textfield
|
|
190
218
|
placeholder="Enter your number"
|
|
191
219
|
value="123"
|
|
192
220
|
required
|
|
193
221
|
multiline
|
|
194
222
|
></sp-textfield>
|
|
195
|
-
`
|
|
223
|
+
`
|
|
224
|
+
);
|
|
196
225
|
await elementUpdated(el);
|
|
197
226
|
expect(el).to.not.equal(void 0);
|
|
198
227
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
199
228
|
expect(input).to.not.be.null;
|
|
200
229
|
});
|
|
201
230
|
it("valid - boundary-type assertions", async () => {
|
|
202
|
-
const el = await litFixture(
|
|
231
|
+
const el = await litFixture(
|
|
232
|
+
html`
|
|
203
233
|
<sp-textfield
|
|
204
234
|
placeholder="Enter your number"
|
|
205
235
|
pattern="^[\\d]+$"
|
|
206
236
|
value="123"
|
|
207
237
|
required
|
|
208
238
|
></sp-textfield>
|
|
209
|
-
`
|
|
239
|
+
`
|
|
240
|
+
);
|
|
210
241
|
await elementUpdated(el);
|
|
211
242
|
expect(el).to.not.equal(void 0);
|
|
212
243
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
213
244
|
expect(input).to.not.be.null;
|
|
214
245
|
});
|
|
215
246
|
it("valid - multiline - boundary-type assertions", async () => {
|
|
216
|
-
const el = await litFixture(
|
|
247
|
+
const el = await litFixture(
|
|
248
|
+
html`
|
|
217
249
|
<sp-textfield
|
|
218
250
|
placeholder="Enter your number"
|
|
219
251
|
pattern="^[\\d]+$"
|
|
@@ -221,28 +253,32 @@ describe("Textfield", () => {
|
|
|
221
253
|
required
|
|
222
254
|
multiline
|
|
223
255
|
></sp-textfield>
|
|
224
|
-
`
|
|
256
|
+
`
|
|
257
|
+
);
|
|
225
258
|
await elementUpdated(el);
|
|
226
259
|
expect(el).to.not.equal(void 0);
|
|
227
260
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
228
261
|
expect(input).to.not.be.null;
|
|
229
262
|
});
|
|
230
263
|
it("valid - unicode", async () => {
|
|
231
|
-
const el = await litFixture(
|
|
264
|
+
const el = await litFixture(
|
|
265
|
+
html`
|
|
232
266
|
<sp-textfield
|
|
233
267
|
placeholder="Enter your name"
|
|
234
268
|
pattern="\\p{L}{4,8}"
|
|
235
269
|
value="你的名字"
|
|
236
270
|
required
|
|
237
271
|
></sp-textfield>
|
|
238
|
-
`
|
|
272
|
+
`
|
|
273
|
+
);
|
|
239
274
|
await elementUpdated(el);
|
|
240
275
|
expect(el).to.not.equal(void 0);
|
|
241
276
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
242
277
|
expect(input).to.not.be.null;
|
|
243
278
|
});
|
|
244
279
|
it("valid - multiline - unicode", async () => {
|
|
245
|
-
const el = await litFixture(
|
|
280
|
+
const el = await litFixture(
|
|
281
|
+
html`
|
|
246
282
|
<sp-textfield
|
|
247
283
|
placeholder="Enter your name"
|
|
248
284
|
pattern="\\p{L}{4,8}"
|
|
@@ -250,28 +286,32 @@ describe("Textfield", () => {
|
|
|
250
286
|
required
|
|
251
287
|
multiline
|
|
252
288
|
></sp-textfield>
|
|
253
|
-
`
|
|
289
|
+
`
|
|
290
|
+
);
|
|
254
291
|
await elementUpdated(el);
|
|
255
292
|
expect(el).to.not.equal(void 0);
|
|
256
293
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#valid") : null;
|
|
257
294
|
expect(input).to.not.be.null;
|
|
258
295
|
});
|
|
259
296
|
it("invalid", async () => {
|
|
260
|
-
const el = await litFixture(
|
|
297
|
+
const el = await litFixture(
|
|
298
|
+
html`
|
|
261
299
|
<sp-textfield
|
|
262
300
|
placeholder="Enter your number"
|
|
263
301
|
pattern="[\\d]+"
|
|
264
302
|
value="123 not valid"
|
|
265
303
|
required
|
|
266
304
|
></sp-textfield>
|
|
267
|
-
`
|
|
305
|
+
`
|
|
306
|
+
);
|
|
268
307
|
await elementUpdated(el);
|
|
269
308
|
expect(el).to.not.equal(void 0);
|
|
270
309
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
271
310
|
expect(input).to.not.be.null;
|
|
272
311
|
});
|
|
273
312
|
it("invalid - multiline", async () => {
|
|
274
|
-
const el = await litFixture(
|
|
313
|
+
const el = await litFixture(
|
|
314
|
+
html`
|
|
275
315
|
<sp-textfield
|
|
276
316
|
placeholder="Enter your number"
|
|
277
317
|
pattern="[\\d]+"
|
|
@@ -279,55 +319,63 @@ describe("Textfield", () => {
|
|
|
279
319
|
required
|
|
280
320
|
multiline
|
|
281
321
|
></sp-textfield>
|
|
282
|
-
`
|
|
322
|
+
`
|
|
323
|
+
);
|
|
283
324
|
await elementUpdated(el);
|
|
284
325
|
expect(el).to.not.equal(void 0);
|
|
285
326
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
286
327
|
expect(input).to.not.be.null;
|
|
287
328
|
});
|
|
288
329
|
it("invalid - required", async () => {
|
|
289
|
-
const el = await litFixture(
|
|
330
|
+
const el = await litFixture(
|
|
331
|
+
html`
|
|
290
332
|
<sp-textfield
|
|
291
333
|
placeholder="Enter your number"
|
|
292
334
|
value=""
|
|
293
335
|
required
|
|
294
336
|
></sp-textfield>
|
|
295
|
-
`
|
|
337
|
+
`
|
|
338
|
+
);
|
|
296
339
|
await elementUpdated(el);
|
|
297
340
|
expect(el).to.not.equal(void 0);
|
|
298
341
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
299
342
|
expect(input).to.not.be.null;
|
|
300
343
|
});
|
|
301
344
|
it("invalid - multiline - required", async () => {
|
|
302
|
-
const el = await litFixture(
|
|
345
|
+
const el = await litFixture(
|
|
346
|
+
html`
|
|
303
347
|
<sp-textfield
|
|
304
348
|
placeholder="Enter your number"
|
|
305
349
|
value=""
|
|
306
350
|
required
|
|
307
351
|
multiline
|
|
308
352
|
></sp-textfield>
|
|
309
|
-
`
|
|
353
|
+
`
|
|
354
|
+
);
|
|
310
355
|
await elementUpdated(el);
|
|
311
356
|
expect(el).to.not.equal(void 0);
|
|
312
357
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
313
358
|
expect(input).to.not.be.null;
|
|
314
359
|
});
|
|
315
360
|
it("invalid - unicode", async () => {
|
|
316
|
-
const el = await litFixture(
|
|
361
|
+
const el = await litFixture(
|
|
362
|
+
html`
|
|
317
363
|
<sp-textfield
|
|
318
364
|
placeholder="Enter your number"
|
|
319
365
|
pattern="\\p{N}+"
|
|
320
366
|
value="123 not valid"
|
|
321
367
|
required
|
|
322
368
|
></sp-textfield>
|
|
323
|
-
`
|
|
369
|
+
`
|
|
370
|
+
);
|
|
324
371
|
await elementUpdated(el);
|
|
325
372
|
expect(el).to.not.equal(void 0);
|
|
326
373
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
327
374
|
expect(input).to.not.be.null;
|
|
328
375
|
});
|
|
329
376
|
it("invalid - multiline - unicode", async () => {
|
|
330
|
-
const el = await litFixture(
|
|
377
|
+
const el = await litFixture(
|
|
378
|
+
html`
|
|
331
379
|
<sp-textfield
|
|
332
380
|
placeholder="Enter your number"
|
|
333
381
|
pattern="\\p{N}+"
|
|
@@ -335,28 +383,32 @@ describe("Textfield", () => {
|
|
|
335
383
|
required
|
|
336
384
|
multiline
|
|
337
385
|
></sp-textfield>
|
|
338
|
-
`
|
|
386
|
+
`
|
|
387
|
+
);
|
|
339
388
|
await elementUpdated(el);
|
|
340
389
|
expect(el).to.not.equal(void 0);
|
|
341
390
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
342
391
|
expect(input).to.not.be.null;
|
|
343
392
|
});
|
|
344
393
|
it("invalid - boundary-type assertions", async () => {
|
|
345
|
-
const el = await litFixture(
|
|
394
|
+
const el = await litFixture(
|
|
395
|
+
html`
|
|
346
396
|
<sp-textfield
|
|
347
397
|
placeholder="Enter your number"
|
|
348
398
|
pattern="^\\p{N}+$"
|
|
349
399
|
value="123 not valid"
|
|
350
400
|
required
|
|
351
401
|
></sp-textfield>
|
|
352
|
-
`
|
|
402
|
+
`
|
|
403
|
+
);
|
|
353
404
|
await elementUpdated(el);
|
|
354
405
|
expect(el).to.not.equal(void 0);
|
|
355
406
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
356
407
|
expect(input).to.not.be.null;
|
|
357
408
|
});
|
|
358
409
|
it("invalid - multiline - boundary-type assertions", async () => {
|
|
359
|
-
const el = await litFixture(
|
|
410
|
+
const el = await litFixture(
|
|
411
|
+
html`
|
|
360
412
|
<sp-textfield
|
|
361
413
|
placeholder="Enter your number"
|
|
362
414
|
pattern="^\\p{N}+$"
|
|
@@ -364,7 +416,8 @@ describe("Textfield", () => {
|
|
|
364
416
|
required
|
|
365
417
|
multiline
|
|
366
418
|
></sp-textfield>
|
|
367
|
-
`
|
|
419
|
+
`
|
|
420
|
+
);
|
|
368
421
|
await elementUpdated(el);
|
|
369
422
|
expect(el).to.not.equal(void 0);
|
|
370
423
|
const input = el.shadowRoot ? el.shadowRoot.querySelector("#invalid") : null;
|
|
@@ -377,9 +430,11 @@ describe("Textfield", () => {
|
|
|
377
430
|
activeElement = path[0];
|
|
378
431
|
};
|
|
379
432
|
document.addEventListener("focusin", onFocusIn);
|
|
380
|
-
const el = await litFixture(
|
|
433
|
+
const el = await litFixture(
|
|
434
|
+
html`
|
|
381
435
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
382
|
-
`
|
|
436
|
+
`
|
|
437
|
+
);
|
|
383
438
|
await elementUpdated(el);
|
|
384
439
|
el.focus();
|
|
385
440
|
await elementUpdated(el);
|
|
@@ -393,12 +448,14 @@ describe("Textfield", () => {
|
|
|
393
448
|
activeElement = path[0];
|
|
394
449
|
};
|
|
395
450
|
document.addEventListener("focusin", onFocusIn);
|
|
396
|
-
const el = await litFixture(
|
|
451
|
+
const el = await litFixture(
|
|
452
|
+
html`
|
|
397
453
|
<sp-textfield
|
|
398
454
|
disabled
|
|
399
455
|
placeholder="Enter your name"
|
|
400
456
|
></sp-textfield>
|
|
401
|
-
`
|
|
457
|
+
`
|
|
458
|
+
);
|
|
402
459
|
await elementUpdated(el);
|
|
403
460
|
el.focus();
|
|
404
461
|
await elementUpdated(el);
|
|
@@ -413,9 +470,11 @@ describe("Textfield", () => {
|
|
|
413
470
|
});
|
|
414
471
|
it("accepts input", async () => {
|
|
415
472
|
const testValue = "Test Name";
|
|
416
|
-
const el = await litFixture(
|
|
473
|
+
const el = await litFixture(
|
|
474
|
+
html`
|
|
417
475
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
418
|
-
`
|
|
476
|
+
`
|
|
477
|
+
);
|
|
419
478
|
await elementUpdated(el);
|
|
420
479
|
el.focusElement.value = testValue;
|
|
421
480
|
el.focusElement.dispatchEvent(new Event("input"));
|
|
@@ -423,9 +482,11 @@ describe("Textfield", () => {
|
|
|
423
482
|
});
|
|
424
483
|
it("selects", async () => {
|
|
425
484
|
const testValue = "Test Name";
|
|
426
|
-
const el = await litFixture(
|
|
485
|
+
const el = await litFixture(
|
|
486
|
+
html`
|
|
427
487
|
<sp-textfield value=${testValue}></sp-textfield>
|
|
428
|
-
`
|
|
488
|
+
`
|
|
489
|
+
);
|
|
429
490
|
await elementUpdated(el);
|
|
430
491
|
expect(el.value).to.equal(testValue);
|
|
431
492
|
el.focus();
|
|
@@ -435,9 +496,11 @@ describe("Textfield", () => {
|
|
|
435
496
|
});
|
|
436
497
|
it("setSelectionRange", async () => {
|
|
437
498
|
const testValue = "Test Name";
|
|
438
|
-
const el = await litFixture(
|
|
499
|
+
const el = await litFixture(
|
|
500
|
+
html`
|
|
439
501
|
<sp-textfield value=${testValue}></sp-textfield>
|
|
440
|
-
`
|
|
502
|
+
`
|
|
503
|
+
);
|
|
441
504
|
await elementUpdated(el);
|
|
442
505
|
expect(el.value).to.equal(testValue);
|
|
443
506
|
el.focus();
|
|
@@ -446,14 +509,16 @@ describe("Textfield", () => {
|
|
|
446
509
|
expect(el.value).to.equal("Name");
|
|
447
510
|
});
|
|
448
511
|
it("accepts maxlength", async () => {
|
|
449
|
-
const el = await litFixture(
|
|
512
|
+
const el = await litFixture(
|
|
513
|
+
html`
|
|
450
514
|
<sp-textfield
|
|
451
515
|
placeholder="Enter your name"
|
|
452
516
|
maxlength="3"
|
|
453
517
|
minlength="2"
|
|
454
518
|
required
|
|
455
519
|
></sp-textfield>
|
|
456
|
-
`
|
|
520
|
+
`
|
|
521
|
+
);
|
|
457
522
|
await elementUpdated(el);
|
|
458
523
|
el.focus();
|
|
459
524
|
await sendKeys({
|
|
@@ -499,12 +564,14 @@ describe("Textfield", () => {
|
|
|
499
564
|
const onChange = (event) => {
|
|
500
565
|
eventSource = event.composedPath()[0];
|
|
501
566
|
};
|
|
502
|
-
const el = await litFixture(
|
|
567
|
+
const el = await litFixture(
|
|
568
|
+
html`
|
|
503
569
|
<sp-textfield
|
|
504
570
|
placeholder="Enter your name"
|
|
505
571
|
@change=${onChange}
|
|
506
572
|
></sp-textfield>
|
|
507
|
-
`
|
|
573
|
+
`
|
|
574
|
+
);
|
|
508
575
|
await elementUpdated(el);
|
|
509
576
|
el.focusElement.value = testValue;
|
|
510
577
|
el.focusElement.dispatchEvent(new Event("input"));
|
|
@@ -514,18 +581,22 @@ describe("Textfield", () => {
|
|
|
514
581
|
expect(testSource).to.equal(el);
|
|
515
582
|
});
|
|
516
583
|
it("passes through `autocomplete` attribute", async () => {
|
|
517
|
-
let el = await litFixture(
|
|
584
|
+
let el = await litFixture(
|
|
585
|
+
html`
|
|
518
586
|
<sp-textfield autocomplete="off"></sp-textfield>
|
|
519
|
-
`
|
|
587
|
+
`
|
|
588
|
+
);
|
|
520
589
|
await elementUpdated(el);
|
|
521
590
|
let input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
522
591
|
expect(input).to.exist;
|
|
523
592
|
if (input) {
|
|
524
593
|
expect(input.getAttribute("autocomplete")).to.equal("off");
|
|
525
594
|
}
|
|
526
|
-
el = await litFixture(
|
|
595
|
+
el = await litFixture(
|
|
596
|
+
html`
|
|
527
597
|
<sp-textfield></sp-textfield>
|
|
528
|
-
`
|
|
598
|
+
`
|
|
599
|
+
);
|
|
529
600
|
await elementUpdated(el);
|
|
530
601
|
input = el.shadowRoot ? el.shadowRoot.querySelector("input") : null;
|
|
531
602
|
expect(input).to.exist;
|
|
@@ -534,9 +605,11 @@ describe("Textfield", () => {
|
|
|
534
605
|
}
|
|
535
606
|
});
|
|
536
607
|
it("tests on `required` changes", async () => {
|
|
537
|
-
const el = await litFixture(
|
|
608
|
+
const el = await litFixture(
|
|
609
|
+
html`
|
|
538
610
|
<sp-textfield value=""></sp-textfield>
|
|
539
|
-
`
|
|
611
|
+
`
|
|
612
|
+
);
|
|
540
613
|
await elementUpdated(el);
|
|
541
614
|
expect(el.invalid).to.be.false;
|
|
542
615
|
el.required = true;
|
|
@@ -544,9 +617,11 @@ describe("Textfield", () => {
|
|
|
544
617
|
expect(el.invalid).to.be.true;
|
|
545
618
|
});
|
|
546
619
|
it("manages `allowed-keys`", async () => {
|
|
547
|
-
const el = await litFixture(
|
|
620
|
+
const el = await litFixture(
|
|
621
|
+
html`
|
|
548
622
|
<sp-textfield allowed-keys="asdf"></sp-textfield>
|
|
549
|
-
`
|
|
623
|
+
`
|
|
624
|
+
);
|
|
550
625
|
await elementUpdated(el);
|
|
551
626
|
expect(el.value).to.equal("");
|
|
552
627
|
const inputElement = el.focusElement;
|
|
@@ -577,39 +652,49 @@ describe("Textfield", () => {
|
|
|
577
652
|
"password"
|
|
578
653
|
];
|
|
579
654
|
for await (const t of types) {
|
|
580
|
-
const el = await litFixture(
|
|
655
|
+
const el = await litFixture(
|
|
656
|
+
html`
|
|
581
657
|
<sp-textfield type=${t}></sp-textfield>
|
|
582
|
-
`
|
|
658
|
+
`
|
|
659
|
+
);
|
|
583
660
|
expect(el.type).equals(t);
|
|
584
661
|
el.setAttribute("type", "url");
|
|
585
662
|
expect(el.type).equals("url");
|
|
586
663
|
}
|
|
587
664
|
});
|
|
588
665
|
it('represents invalid and missing attributes as "text"', async () => {
|
|
589
|
-
const el1 = await litFixture(
|
|
666
|
+
const el1 = await litFixture(
|
|
667
|
+
html`
|
|
590
668
|
<sp-textfield></sp-textfield>
|
|
591
|
-
`
|
|
592
|
-
|
|
669
|
+
`
|
|
670
|
+
);
|
|
671
|
+
const el2 = await litFixture(
|
|
672
|
+
html`
|
|
593
673
|
<sp-textfield type="time"></sp-textfield>
|
|
594
|
-
`
|
|
674
|
+
`
|
|
675
|
+
);
|
|
595
676
|
expect(el1.type).equals("text");
|
|
596
677
|
expect(el2.type).equals("text");
|
|
597
678
|
el1.setAttribute("type", "submit");
|
|
598
679
|
expect(el1.type).equals("text");
|
|
599
680
|
});
|
|
600
681
|
it("reflects valid property assignments", async () => {
|
|
601
|
-
const el = await litFixture(
|
|
682
|
+
const el = await litFixture(
|
|
683
|
+
html`
|
|
602
684
|
<sp-textfield type="url"></sp-textfield>
|
|
603
|
-
`
|
|
685
|
+
`
|
|
686
|
+
);
|
|
604
687
|
el.type = "email";
|
|
605
688
|
await elementUpdated(el);
|
|
606
689
|
expect(el.getAttribute("type")).equals("email");
|
|
607
690
|
expect(el.type).equals("email");
|
|
608
691
|
});
|
|
609
692
|
it('reflects invalid assignments but sets state to "text"', async () => {
|
|
610
|
-
const el = await litFixture(
|
|
693
|
+
const el = await litFixture(
|
|
694
|
+
html`
|
|
611
695
|
<sp-textfield type="url"></sp-textfield>
|
|
612
|
-
`
|
|
696
|
+
`
|
|
697
|
+
);
|
|
613
698
|
el.type = "range";
|
|
614
699
|
await elementUpdated(el);
|
|
615
700
|
expect(el.getAttribute("type")).equals("range");
|
|
@@ -649,7 +734,9 @@ describe("Textfield", () => {
|
|
|
649
734
|
</sp-help-text>
|
|
650
735
|
</sp-textfield>
|
|
651
736
|
`);
|
|
652
|
-
const negativeHelpText = el.querySelector(
|
|
737
|
+
const negativeHelpText = el.querySelector(
|
|
738
|
+
'[slot="negative-help-text"]'
|
|
739
|
+
);
|
|
653
740
|
await elementUpdated(el);
|
|
654
741
|
expect(negativeHelpText.variant).to.equal("neutral");
|
|
655
742
|
await findDescribedNode(name, description);
|
|
@@ -669,7 +756,9 @@ describe("Textfield", () => {
|
|
|
669
756
|
</sp-help-text>
|
|
670
757
|
</sp-textfield>
|
|
671
758
|
`);
|
|
672
|
-
const negativeHelpText = el.querySelector(
|
|
759
|
+
const negativeHelpText = el.querySelector(
|
|
760
|
+
'[slot="negative-help-text"]'
|
|
761
|
+
);
|
|
673
762
|
await elementUpdated(el);
|
|
674
763
|
expect(negativeHelpText.variant).to.equal("neutral");
|
|
675
764
|
await findDescribedNode(name, description);
|