@spectrum-web-components/textfield 0.12.1-devmode.0 → 0.13.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/package.json +8 -8
- package/sp-textfield.js +1 -2
- package/sp-textfield.js.map +1 -1
- package/src/Textfield.js +23 -253
- package/src/Textfield.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-textfield.css.js +2 -4
- package/src/spectrum-textfield.css.js.map +1 -1
- package/src/textfield.css.js +2 -4
- package/src/textfield.css.js.map +1 -1
- package/stories/textarea.stories.js +8 -25
- package/stories/textarea.stories.js.map +1 -1
- package/stories/textfield.stories.js +8 -31
- package/stories/textfield.stories.js.map +1 -1
- package/test/benchmark/test-basic.js +1 -4
- package/test/benchmark/test-basic.js.map +1 -1
- package/test/textarea.test-vrt.js +1 -3
- package/test/textarea.test-vrt.js.map +1 -1
- package/test/textfield.test-vrt.js +1 -3
- package/test/textfield.test-vrt.js.map +1 -1
- package/test/textfield.test.js +60 -522
- package/test/textfield.test.js.map +1 -1
package/test/textfield.test.js
CHANGED
|
@@ -1,163 +1,45 @@
|
|
|
1
|
-
import
|
|
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`
|
|
1
|
+
import{elementUpdated as a,expect as l,html as i,litFixture as n}from"@open-wc/testing";import{sendKeys as u}from"@web/test-runner-commands";import{sendMouse as p}from"../../../test/plugins/browser.js";import{findDescribedNode as r}from"../../../test/testing-helpers-a11y.js";import"@spectrum-web-components/help-text/sp-help-text.js";import"@spectrum-web-components/textfield/sp-textfield.js";import{testForLitDevWarnings as f}from"../../../test/testing-helpers.js";describe("Textfield",()=>{f(async()=>await n(i`
|
|
10
2
|
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
11
|
-
`))
|
|
12
|
-
it("loads default textfield accessibly", async () => {
|
|
13
|
-
const el = await litFixture(html`
|
|
3
|
+
`)),it("loads default textfield accessibly",async()=>{const e=await n(i`
|
|
14
4
|
<sp-textfield label="Enter Your Name"></sp-textfield>
|
|
15
|
-
`);
|
|
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`
|
|
5
|
+
`);await a(e),await l(e).to.be.accessible()}),it("loads multiline textfield accessibly",async()=>{const e=await n(i`
|
|
21
6
|
<sp-textfield label="Enter your name" multiline></sp-textfield>
|
|
22
|
-
`);
|
|
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`
|
|
7
|
+
`);await a(e),await l(e).to.be.accessible()}),it("manages tabIndex while disabled",async()=>{const e=await n(i`
|
|
28
8
|
<sp-textfield placeholder="Enter Your Name"></sp-textfield>
|
|
29
|
-
`);
|
|
30
|
-
|
|
31
|
-
|
|
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`
|
|
51
|
-
<sp-textfield placeholder=${testPlaceholder}></sp-textfield>
|
|
52
|
-
`);
|
|
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`
|
|
9
|
+
`);await a(e),l(e.tabIndex).to.equal(0),e.disabled=!0,await a(e),l(e.tabIndex).to.equal(-1),e.tabIndex=2,await a(e),l(e.tabIndex).to.equal(-1),e.disabled=!1,await a(e),l(e.tabIndex).to.equal(2)}),it("manages tabIndex before first render",async()=>{const e=document.createElement("sp-textfield");l(e.focusElement).to.be.null,l(e.tabIndex).to.equal(0),e.remove()}),it("loads",async()=>{const e="Enter your name",t=await n(i`
|
|
10
|
+
<sp-textfield placeholder=${e}></sp-textfield>
|
|
11
|
+
`);l(t).to.not.equal(void 0);const o=t.shadowRoot?t.shadowRoot.querySelector("input"):null;l(o).to.not.be.null;const s=o?o.placeholder:null;l(s).to.equal(e)}),it("multiline",async()=>{const e=await n(i`
|
|
61
12
|
<sp-textfield
|
|
62
13
|
placeholder="Enter your name"
|
|
63
14
|
multiline
|
|
64
15
|
></sp-textfield>
|
|
65
|
-
`);
|
|
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`
|
|
16
|
+
`);l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("textarea"):null;l(t).to.not.be.null}),it("resizes by default",async()=>{const e=await n(i`
|
|
72
17
|
<sp-textfield
|
|
73
18
|
multiline
|
|
74
19
|
label="No resize control"
|
|
75
20
|
placeholder="No resize control"
|
|
76
21
|
></sp-textfield>
|
|
77
|
-
`);
|
|
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`
|
|
22
|
+
`),t=e.getBoundingClientRect();await p({steps:[{type:"move",position:[t.right-2,t.bottom-2]},{type:"down"},{type:"move",position:[t.right+50,t.bottom+50]},{type:"up"}]});const o=e.getBoundingClientRect();l(o.width).to.be.greaterThan(t.width),l(o.height).to.be.greaterThan(t.height)}),it("accepts resize styling",async()=>{const e=await n(i`
|
|
103
23
|
<sp-textfield
|
|
104
24
|
multiline
|
|
105
25
|
style="resize: none;"
|
|
106
26
|
label="No resize control"
|
|
107
27
|
placeholder="No resize control"
|
|
108
28
|
></sp-textfield>
|
|
109
|
-
`);
|
|
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`
|
|
29
|
+
`),t=e.getBoundingClientRect();await p({steps:[{type:"move",position:[t.right-2,t.bottom-2]},{type:"down"},{type:"move",position:[t.right+50,t.bottom+50]},{type:"up"}]});const o=e.getBoundingClientRect();l(o.width).equals(t.width),l(o.height).equals(t.height)}),it("grows",async()=>{const e=await n(i`
|
|
135
30
|
<sp-textfield
|
|
136
31
|
placeholder="Enter your name"
|
|
137
32
|
multiline
|
|
138
33
|
grows
|
|
139
34
|
></sp-textfield>
|
|
140
|
-
`);
|
|
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`
|
|
35
|
+
`);l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#sizer"):null;l(t).to.not.be.null}),it("valid",async()=>{const e=await n(i`
|
|
147
36
|
<sp-textfield
|
|
148
37
|
placeholder="Enter your number"
|
|
149
38
|
pattern="[\\d]+"
|
|
150
39
|
value="123"
|
|
151
40
|
required
|
|
152
41
|
></sp-textfield>
|
|
153
|
-
`);
|
|
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`
|
|
42
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - multiline",async()=>{const e=await n(i`
|
|
161
43
|
<sp-textfield
|
|
162
44
|
placeholder="Enter your number"
|
|
163
45
|
pattern="[\\d]+"
|
|
@@ -165,55 +47,27 @@ describe("Textfield", () => {
|
|
|
165
47
|
required
|
|
166
48
|
multiline
|
|
167
49
|
></sp-textfield>
|
|
168
|
-
`);
|
|
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`
|
|
50
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - required",async()=>{const e=await n(i`
|
|
176
51
|
<sp-textfield
|
|
177
52
|
placeholder="Enter your number"
|
|
178
53
|
value="123"
|
|
179
54
|
required
|
|
180
55
|
></sp-textfield>
|
|
181
|
-
`);
|
|
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`
|
|
56
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - multiline - required",async()=>{const e=await n(i`
|
|
189
57
|
<sp-textfield
|
|
190
58
|
placeholder="Enter your number"
|
|
191
59
|
value="123"
|
|
192
60
|
required
|
|
193
61
|
multiline
|
|
194
62
|
></sp-textfield>
|
|
195
|
-
`);
|
|
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`
|
|
63
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - boundary-type assertions",async()=>{const e=await n(i`
|
|
203
64
|
<sp-textfield
|
|
204
65
|
placeholder="Enter your number"
|
|
205
66
|
pattern="^[\\d]+$"
|
|
206
67
|
value="123"
|
|
207
68
|
required
|
|
208
69
|
></sp-textfield>
|
|
209
|
-
`);
|
|
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`
|
|
70
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - multiline - boundary-type assertions",async()=>{const e=await n(i`
|
|
217
71
|
<sp-textfield
|
|
218
72
|
placeholder="Enter your number"
|
|
219
73
|
pattern="^[\\d]+$"
|
|
@@ -221,28 +75,14 @@ describe("Textfield", () => {
|
|
|
221
75
|
required
|
|
222
76
|
multiline
|
|
223
77
|
></sp-textfield>
|
|
224
|
-
`);
|
|
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`
|
|
78
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - unicode",async()=>{const e=await n(i`
|
|
232
79
|
<sp-textfield
|
|
233
80
|
placeholder="Enter your name"
|
|
234
81
|
pattern="\\p{L}{4,8}"
|
|
235
82
|
value="你的名字"
|
|
236
83
|
required
|
|
237
84
|
></sp-textfield>
|
|
238
|
-
`);
|
|
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`
|
|
85
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("valid - multiline - unicode",async()=>{const e=await n(i`
|
|
246
86
|
<sp-textfield
|
|
247
87
|
placeholder="Enter your name"
|
|
248
88
|
pattern="\\p{L}{4,8}"
|
|
@@ -250,28 +90,14 @@ describe("Textfield", () => {
|
|
|
250
90
|
required
|
|
251
91
|
multiline
|
|
252
92
|
></sp-textfield>
|
|
253
|
-
`);
|
|
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`
|
|
93
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#valid"):null;l(t).to.not.be.null}),it("invalid",async()=>{const e=await n(i`
|
|
261
94
|
<sp-textfield
|
|
262
95
|
placeholder="Enter your number"
|
|
263
96
|
pattern="[\\d]+"
|
|
264
97
|
value="123 not valid"
|
|
265
98
|
required
|
|
266
99
|
></sp-textfield>
|
|
267
|
-
`);
|
|
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`
|
|
100
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - multiline",async()=>{const e=await n(i`
|
|
275
101
|
<sp-textfield
|
|
276
102
|
placeholder="Enter your number"
|
|
277
103
|
pattern="[\\d]+"
|
|
@@ -279,55 +105,27 @@ describe("Textfield", () => {
|
|
|
279
105
|
required
|
|
280
106
|
multiline
|
|
281
107
|
></sp-textfield>
|
|
282
|
-
`);
|
|
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`
|
|
108
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - required",async()=>{const e=await n(i`
|
|
290
109
|
<sp-textfield
|
|
291
110
|
placeholder="Enter your number"
|
|
292
111
|
value=""
|
|
293
112
|
required
|
|
294
113
|
></sp-textfield>
|
|
295
|
-
`);
|
|
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`
|
|
114
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - multiline - required",async()=>{const e=await n(i`
|
|
303
115
|
<sp-textfield
|
|
304
116
|
placeholder="Enter your number"
|
|
305
117
|
value=""
|
|
306
118
|
required
|
|
307
119
|
multiline
|
|
308
120
|
></sp-textfield>
|
|
309
|
-
`);
|
|
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`
|
|
121
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - unicode",async()=>{const e=await n(i`
|
|
317
122
|
<sp-textfield
|
|
318
123
|
placeholder="Enter your number"
|
|
319
124
|
pattern="\\p{N}+"
|
|
320
125
|
value="123 not valid"
|
|
321
126
|
required
|
|
322
127
|
></sp-textfield>
|
|
323
|
-
`);
|
|
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`
|
|
128
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - multiline - unicode",async()=>{const e=await n(i`
|
|
331
129
|
<sp-textfield
|
|
332
130
|
placeholder="Enter your number"
|
|
333
131
|
pattern="\\p{N}+"
|
|
@@ -335,28 +133,14 @@ describe("Textfield", () => {
|
|
|
335
133
|
required
|
|
336
134
|
multiline
|
|
337
135
|
></sp-textfield>
|
|
338
|
-
`);
|
|
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`
|
|
136
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - boundary-type assertions",async()=>{const e=await n(i`
|
|
346
137
|
<sp-textfield
|
|
347
138
|
placeholder="Enter your number"
|
|
348
139
|
pattern="^\\p{N}+$"
|
|
349
140
|
value="123 not valid"
|
|
350
141
|
required
|
|
351
142
|
></sp-textfield>
|
|
352
|
-
`);
|
|
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`
|
|
143
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("invalid - multiline - boundary-type assertions",async()=>{const e=await n(i`
|
|
360
144
|
<sp-textfield
|
|
361
145
|
placeholder="Enter your number"
|
|
362
146
|
pattern="^\\p{N}+$"
|
|
@@ -364,320 +148,74 @@ describe("Textfield", () => {
|
|
|
364
148
|
required
|
|
365
149
|
multiline
|
|
366
150
|
></sp-textfield>
|
|
367
|
-
`);
|
|
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`
|
|
151
|
+
`);await a(e),l(e).to.not.equal(void 0);const t=e.shadowRoot?e.shadowRoot.querySelector("#invalid"):null;l(t).to.not.be.null}),it("receives focus",async()=>{let e=null;const t=s=>{e=s.composedPath()[0]};document.addEventListener("focusin",t);const o=await n(i`
|
|
381
152
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
382
|
-
`);
|
|
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`
|
|
153
|
+
`);await a(o),o.focus(),await a(o),l(e===o.focusElement).to.be.true,document.removeEventListener("focusin",t)}),it("does not receive focus when disabled",async()=>{let e=null;const t=s=>{e=s.composedPath()[0]};document.addEventListener("focusin",t);const o=await n(i`
|
|
397
154
|
<sp-textfield
|
|
398
155
|
disabled
|
|
399
156
|
placeholder="Enter your name"
|
|
400
157
|
></sp-textfield>
|
|
401
|
-
`);
|
|
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`
|
|
158
|
+
`);await a(o),o.focus(),await a(o),l(e===o.focusElement).to.be.false,l(document.activeElement===o).to.be.false,document.removeEventListener("focusin",t),o.click(),await a(o),l(e===o.focusElement).to.be.false,l(document.activeElement===o).to.be.false,document.removeEventListener("focusin",t)}),it("accepts input",async()=>{const e="Test Name",t=await n(i`
|
|
417
159
|
<sp-textfield placeholder="Enter your name"></sp-textfield>
|
|
418
|
-
`);
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
});
|
|
424
|
-
it("selects", async () => {
|
|
425
|
-
const testValue = "Test Name";
|
|
426
|
-
const el = await litFixture(html`
|
|
427
|
-
<sp-textfield value=${testValue}></sp-textfield>
|
|
428
|
-
`);
|
|
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`
|
|
439
|
-
<sp-textfield value=${testValue}></sp-textfield>
|
|
440
|
-
`);
|
|
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`
|
|
160
|
+
`);await a(t),t.focusElement.value=e,t.focusElement.dispatchEvent(new Event("input")),l(t.value).to.equal(e)}),it("selects",async()=>{const e="Test Name",t=await n(i`
|
|
161
|
+
<sp-textfield value=${e}></sp-textfield>
|
|
162
|
+
`);await a(t),l(t.value).to.equal(e),t.focus(),t.select(),await u({press:"Backspace"}),l(t.value).to.equal("")}),it("setSelectionRange",async()=>{const e="Test Name",t=await n(i`
|
|
163
|
+
<sp-textfield value=${e}></sp-textfield>
|
|
164
|
+
`);await a(t),l(t.value).to.equal(e),t.focus(),t.setSelectionRange(0,5),await u({press:"Backspace"}),l(t.value).to.equal("Name")}),it("accepts maxlength",async()=>{const e=await n(i`
|
|
450
165
|
<sp-textfield
|
|
451
166
|
placeholder="Enter your name"
|
|
452
167
|
maxlength="3"
|
|
453
168
|
minlength="2"
|
|
454
169
|
required
|
|
455
170
|
></sp-textfield>
|
|
456
|
-
`);
|
|
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`
|
|
171
|
+
`);await a(e),e.focus(),await u({type:"a"}),await a(e),l(e.value).to.equal("a"),l(e.checkValidity()).to.be.false,await u({type:"b"}),await a(e),l(e.value).to.equal("ab"),l(e.checkValidity()),await u({type:"c"}),await a(e),l(e.value).to.equal("abc"),l(e.checkValidity()),await u({type:"d"}),await a(e),l(e.value).to.equal("abc"),l(e.checkValidity()),await u({press:"Backspace"}),await a(e),l(e.value).to.equal("ab"),l(e.checkValidity()),await u({press:"Backspace"}),await a(e),l(e.value).to.equal("a"),l(e.checkValidity()).to.be.false}),it("dispatches a `change` event",async()=>{const e="Test Name";let t=null;const s=await n(i`
|
|
503
172
|
<sp-textfield
|
|
504
173
|
placeholder="Enter your name"
|
|
505
|
-
@change=${
|
|
174
|
+
@change=${c=>{t=c.composedPath()[0]}}
|
|
506
175
|
></sp-textfield>
|
|
507
|
-
`);
|
|
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`
|
|
176
|
+
`);await a(s),s.focusElement.value=e,s.focusElement.dispatchEvent(new Event("input")),s.focusElement.dispatchEvent(new Event("change")),l(s.value).to.equal(e),l(t).to.equal(s)}),it("passes through `autocomplete` attribute",async()=>{let e=await n(i`
|
|
518
177
|
<sp-textfield autocomplete="off"></sp-textfield>
|
|
519
|
-
`);
|
|
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`
|
|
178
|
+
`);await a(e);let t=e.shadowRoot?e.shadowRoot.querySelector("input"):null;l(t).to.exist,t&&l(t.getAttribute("autocomplete")).to.equal("off"),e=await n(i`
|
|
527
179
|
<sp-textfield></sp-textfield>
|
|
528
|
-
`)
|
|
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`
|
|
180
|
+
`),await a(e),t=e.shadowRoot?e.shadowRoot.querySelector("input"):null,l(t).to.exist,t&&l(t.getAttribute("autocomplete")).to.not.exist}),it("tests on `required` changes",async()=>{const e=await n(i`
|
|
538
181
|
<sp-textfield value=""></sp-textfield>
|
|
539
|
-
`);
|
|
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`
|
|
182
|
+
`);await a(e),l(e.invalid).to.be.false,e.required=!0,await a(e),l(e.invalid).to.be.true}),it("manages `allowed-keys`",async()=>{const e=await n(i`
|
|
548
183
|
<sp-textfield allowed-keys="asdf"></sp-textfield>
|
|
549
|
-
`);
|
|
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`
|
|
184
|
+
`);await a(e),l(e.value).to.equal("");const t=e.focusElement;e.focusElement.value="asdf",t.dispatchEvent(new InputEvent("input")),await a(e),l(e.value).to.equal("asdf"),t.value="asdff",t.setSelectionRange(1,1),t.dispatchEvent(new InputEvent("input")),await a(e),l(e.value).to.equal("asdff"),l(t.selectionStart).to.equal(1),t.value="asdoff",t.setSelectionRange(4,4),t.dispatchEvent(new InputEvent("input")),await a(e),l(e.value).to.equal("asdff"),l(t.selectionStart).to.equal(3)}),describe("type attribute",()=>{it("assigns valid attributes to the property",async()=>{const e=["text","url","tel","email","password"];for await(const t of e){const o=await n(i`
|
|
581
185
|
<sp-textfield type=${t}></sp-textfield>
|
|
582
|
-
`);
|
|
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`
|
|
186
|
+
`);l(o.type).equals(t),o.setAttribute("type","url"),l(o.type).equals("url")}}),it('represents invalid and missing attributes as "text"',async()=>{const e=await n(i`
|
|
590
187
|
<sp-textfield></sp-textfield>
|
|
591
|
-
`)
|
|
592
|
-
const el2 = await litFixture(html`
|
|
188
|
+
`),t=await n(i`
|
|
593
189
|
<sp-textfield type="time"></sp-textfield>
|
|
594
|
-
`);
|
|
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`
|
|
190
|
+
`);l(e.type).equals("text"),l(t.type).equals("text"),e.setAttribute("type","submit"),l(e.type).equals("text")}),it("reflects valid property assignments",async()=>{const e=await n(i`
|
|
602
191
|
<sp-textfield type="url"></sp-textfield>
|
|
603
|
-
`);
|
|
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`
|
|
192
|
+
`);e.type="email",await a(e),l(e.getAttribute("type")).equals("email"),l(e.type).equals("email")}),it('reflects invalid assignments but sets state to "text"',async()=>{const e=await n(i`
|
|
611
193
|
<sp-textfield type="url"></sp-textfield>
|
|
612
|
-
`);
|
|
613
|
-
|
|
614
|
-
|
|
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`
|
|
625
|
-
<sp-textfield label=${name}>
|
|
626
|
-
<sp-help-text slot="help-text">${description}</sp-help-text>
|
|
194
|
+
`);e.type="range",await a(e),l(e.getAttribute("type")).equals("range"),l(e.type).equals("text")})}),describe("help text",()=>{const e="This is a textfield",t="This text helps you fill it out",o="This text helps you when invalid";it('accepts help text in `slot="help-text"`',async()=>{const s=await n(i`
|
|
195
|
+
<sp-textfield label=${e}>
|
|
196
|
+
<sp-help-text slot="help-text">${t}</sp-help-text>
|
|
627
197
|
</sp-textfield>
|
|
628
|
-
`);
|
|
629
|
-
|
|
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`
|
|
634
|
-
<sp-textfield label=${name}>
|
|
198
|
+
`);await a(s),await r(e,t)}),it('accepts help text in `slot="help-text"` w/ own ID',async()=>{const s=await n(i`
|
|
199
|
+
<sp-textfield label=${e}>
|
|
635
200
|
<sp-help-text slot="help-text" id="help-text-id-1">
|
|
636
|
-
${
|
|
201
|
+
${t}
|
|
637
202
|
</sp-help-text>
|
|
638
203
|
</sp-textfield>
|
|
639
|
-
`);
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
});
|
|
643
|
-
it("manages neutral/negative help text pairs", async () => {
|
|
644
|
-
const el = await litFixture(html`
|
|
645
|
-
<sp-textfield label=${name}>
|
|
646
|
-
<sp-help-text slot="help-text">${description}</sp-help-text>
|
|
204
|
+
`);await a(s),await r(e,t)}),it("manages neutral/negative help text pairs",async()=>{const s=await n(i`
|
|
205
|
+
<sp-textfield label=${e}>
|
|
206
|
+
<sp-help-text slot="help-text">${t}</sp-help-text>
|
|
647
207
|
<sp-help-text slot="negative-help-text">
|
|
648
|
-
${
|
|
208
|
+
${o}
|
|
649
209
|
</sp-help-text>
|
|
650
210
|
</sp-textfield>
|
|
651
|
-
`);
|
|
652
|
-
|
|
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`
|
|
663
|
-
<sp-textfield label=${name}>
|
|
211
|
+
`),d=s.querySelector('[slot="negative-help-text"]');await a(s),l(d.variant).to.equal("neutral"),await r(e,t),s.invalid=!0,await a(s),l(d.variant).to.equal("negative"),await r(e,o)}),it("manages neutral/negative help text pairs w/ own IDs",async()=>{const s=await n(i`
|
|
212
|
+
<sp-textfield label=${e}>
|
|
664
213
|
<sp-help-text slot="help-text" id="help-text-id-2">
|
|
665
|
-
${
|
|
214
|
+
${t}
|
|
666
215
|
</sp-help-text>
|
|
667
216
|
<sp-help-text slot="negative-help-text" id="help-text-id-3">
|
|
668
|
-
${
|
|
217
|
+
${o}
|
|
669
218
|
</sp-help-text>
|
|
670
219
|
</sp-textfield>
|
|
671
|
-
`);
|
|
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);
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
});
|
|
220
|
+
`),d=s.querySelector('[slot="negative-help-text"]');await a(s),l(d.variant).to.equal("neutral"),await r(e,t),s.invalid=!0,await a(s),l(d.variant).to.equal("negative"),await r(e,o)})})});
|
|
683
221
|
//# sourceMappingURL=textfield.test.js.map
|