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