@spectrum-web-components/action-group 0.9.0 → 0.10.1-devmode.7
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 +23 -10
- package/sp-action-group.dev.js +3 -0
- package/sp-action-group.dev.js.map +7 -0
- package/sp-action-group.js +3 -14
- package/sp-action-group.js.map +7 -1
- package/src/ActionGroup.dev.js +309 -0
- package/src/ActionGroup.dev.js.map +7 -0
- package/src/ActionGroup.js +291 -308
- package/src/ActionGroup.js.map +7 -1
- package/src/action-group.css.dev.js +149 -0
- package/src/action-group.css.dev.js.map +7 -0
- package/src/action-group.css.js +6 -33
- package/src/action-group.css.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-action-group.css.dev.js +143 -0
- package/src/spectrum-action-group.css.dev.js.map +7 -0
- package/src/spectrum-action-group.css.js +3 -14
- package/src/spectrum-action-group.css.js.map +7 -1
- package/stories/action-group-tooltip.stories.js +116 -129
- package/stories/action-group-tooltip.stories.js.map +7 -1
- package/stories/action-group.stories.js +124 -135
- package/stories/action-group.stories.js.map +7 -1
- package/test/action-group-tooltip.test-vrt.js +4 -15
- package/test/action-group-tooltip.test-vrt.js.map +7 -1
- package/test/action-group.test-vrt.js +4 -15
- package/test/action-group.test-vrt.js.map +7 -1
- package/test/action-group.test.js +454 -465
- package/test/action-group.test.js.map +7 -1
- package/test/benchmark/basic-test.js +6 -17
- package/test/benchmark/basic-test.js.map +7 -1
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import {
|
|
2
|
+
elementUpdated,
|
|
3
|
+
expect,
|
|
4
|
+
fixture,
|
|
5
|
+
html,
|
|
6
|
+
waitUntil
|
|
7
|
+
} from "@open-wc/testing";
|
|
8
|
+
import "@spectrum-web-components/action-button/sp-action-button.js";
|
|
9
|
+
import { LitElement } from "@spectrum-web-components/base";
|
|
10
|
+
import "@spectrum-web-components/overlay/overlay-trigger.js";
|
|
11
|
+
import "@spectrum-web-components/tooltip/sp-tooltip.js";
|
|
12
|
+
import {
|
|
13
|
+
arrowDownEvent,
|
|
14
|
+
arrowLeftEvent,
|
|
15
|
+
arrowRightEvent,
|
|
16
|
+
arrowUpEvent,
|
|
17
|
+
endEvent,
|
|
18
|
+
homeEvent
|
|
19
|
+
} from "../../../test/testing-helpers";
|
|
20
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
21
|
+
import "@spectrum-web-components/action-group/sp-action-group.js";
|
|
20
22
|
class QuietActionGroup extends LitElement {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
render() {
|
|
24
|
+
return html`
|
|
23
25
|
<sp-action-group quiet>
|
|
24
26
|
<slot name="first"></slot>
|
|
25
27
|
<slot name="second"></slot>
|
|
26
28
|
</sp-action-group>
|
|
27
29
|
`;
|
|
28
|
-
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
|
-
customElements.define(
|
|
32
|
+
customElements.define("quiet-action-group", QuietActionGroup);
|
|
31
33
|
class EmphasizedActionGroup extends LitElement {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
render() {
|
|
35
|
+
return html`
|
|
34
36
|
<sp-action-group emphasized>
|
|
35
37
|
<slot name="first"></slot>
|
|
36
38
|
<slot name="second"></slot>
|
|
37
39
|
</sp-action-group>
|
|
38
40
|
`;
|
|
39
|
-
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
|
-
customElements.define(
|
|
43
|
+
customElements.define("emphasized-action-group", EmphasizedActionGroup);
|
|
42
44
|
async function singleSelectedActionGroup(selected) {
|
|
43
|
-
|
|
45
|
+
const el = await fixture(html`
|
|
44
46
|
<sp-action-group
|
|
45
47
|
label="Selects User-Chosen Buttons"
|
|
46
48
|
selects="single"
|
|
@@ -54,10 +56,10 @@ async function singleSelectedActionGroup(selected) {
|
|
|
54
56
|
</sp-action-button>
|
|
55
57
|
</sp-action-group>
|
|
56
58
|
`);
|
|
57
|
-
|
|
59
|
+
return el;
|
|
58
60
|
}
|
|
59
61
|
async function multipleSelectedActionGroup(selected) {
|
|
60
|
-
|
|
62
|
+
const el = await fixture(html`
|
|
61
63
|
<sp-action-group
|
|
62
64
|
label="Selects User-Chosen Buttons"
|
|
63
65
|
selects="multiple"
|
|
@@ -71,47 +73,47 @@ async function multipleSelectedActionGroup(selected) {
|
|
|
71
73
|
</sp-action-button>
|
|
72
74
|
</sp-action-group>
|
|
73
75
|
`);
|
|
74
|
-
|
|
76
|
+
return el;
|
|
75
77
|
}
|
|
76
|
-
describe(
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
describe("ActionGroup", () => {
|
|
79
|
+
it("loads empty action-group accessibly", async () => {
|
|
80
|
+
const el = await fixture(html`
|
|
79
81
|
<sp-action-group></sp-action-group>
|
|
80
82
|
`);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
await elementUpdated(el);
|
|
84
|
+
await expect(el).to.be.accessible();
|
|
85
|
+
});
|
|
86
|
+
it("loads default action-group accessibly", async () => {
|
|
87
|
+
const el = await fixture(html`
|
|
86
88
|
<sp-action-group aria-label="Default Group">
|
|
87
89
|
<sp-action-button>First</sp-action-button>
|
|
88
90
|
<sp-action-button>Second</sp-action-button>
|
|
89
91
|
<sp-action-button>Third</sp-action-button>
|
|
90
92
|
</sp-action-group>
|
|
91
93
|
`);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
await elementUpdated(el);
|
|
95
|
+
await expect(el).to.be.accessible();
|
|
96
|
+
expect(el.getAttribute("aria-label")).to.equal("Default Group");
|
|
97
|
+
expect(el.hasAttribute("role")).to.be.false;
|
|
98
|
+
expect(el.children[0].getAttribute("role")).to.equal("button");
|
|
99
|
+
});
|
|
100
|
+
it("applies `quiet` attribute to its children", async () => {
|
|
101
|
+
const el = await fixture(html`
|
|
100
102
|
<sp-action-group quiet>
|
|
101
103
|
<sp-action-button id="first">First</sp-action-button>
|
|
102
104
|
<sp-action-button id="second">Second</sp-action-button>
|
|
103
105
|
</sp-action-group>
|
|
104
106
|
`);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
const firstButton = el.querySelector("#first");
|
|
108
|
+
const secondButton = el.querySelector("#second");
|
|
109
|
+
await elementUpdated(el);
|
|
110
|
+
expect(firstButton.hasAttribute("quiet")).to.be.true;
|
|
111
|
+
expect(firstButton.quiet).to.be.true;
|
|
112
|
+
expect(secondButton.hasAttribute("quiet")).to.be.true;
|
|
113
|
+
expect(secondButton.quiet).to.be.true;
|
|
114
|
+
});
|
|
115
|
+
it("applies `quiet` attribute to its slotted children", async () => {
|
|
116
|
+
const el = await fixture(html`
|
|
115
117
|
<quiet-action-group>
|
|
116
118
|
<sp-action-button slot="first" id="first">
|
|
117
119
|
First
|
|
@@ -121,16 +123,16 @@ describe('ActionGroup', () => {
|
|
|
121
123
|
</sp-action-button>
|
|
122
124
|
</quiet-action-group>
|
|
123
125
|
`);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
const firstButton = el.querySelector("#first");
|
|
127
|
+
const secondButton = el.querySelector("#second");
|
|
128
|
+
await elementUpdated(el);
|
|
129
|
+
expect(firstButton.hasAttribute("quiet")).to.be.true;
|
|
130
|
+
expect(firstButton.quiet).to.be.true;
|
|
131
|
+
expect(secondButton.hasAttribute("quiet")).to.be.true;
|
|
132
|
+
expect(secondButton.quiet).to.be.true;
|
|
133
|
+
});
|
|
134
|
+
it("applies `emphasized` attribute to its slotted children", async () => {
|
|
135
|
+
const el = await fixture(html`
|
|
134
136
|
<emphasized-action-group>
|
|
135
137
|
<sp-action-button slot="first" id="first">
|
|
136
138
|
First
|
|
@@ -140,16 +142,16 @@ describe('ActionGroup', () => {
|
|
|
140
142
|
</sp-action-button>
|
|
141
143
|
</emphasized-action-group>
|
|
142
144
|
`);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
const firstButton = el.querySelector("#first");
|
|
146
|
+
const secondButton = el.querySelector("#second");
|
|
147
|
+
await elementUpdated(el);
|
|
148
|
+
expect(firstButton.hasAttribute("emphasized")).to.be.true;
|
|
149
|
+
expect(firstButton.emphasized).to.be.true;
|
|
150
|
+
expect(secondButton.hasAttribute("emphasized")).to.be.true;
|
|
151
|
+
expect(secondButton.emphasized).to.be.true;
|
|
152
|
+
});
|
|
153
|
+
it("applies `quiet` attribute to slotted children with overlays", async () => {
|
|
154
|
+
const el = await fixture(html`
|
|
153
155
|
<quiet-action-group>
|
|
154
156
|
<overlay-trigger slot="first">
|
|
155
157
|
<sp-action-button slot="trigger" id="first">
|
|
@@ -163,16 +165,16 @@ describe('ActionGroup', () => {
|
|
|
163
165
|
</overlay-trigger>
|
|
164
166
|
</quiet-action-group>
|
|
165
167
|
`);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
const firstButton = el.querySelector("#first");
|
|
169
|
+
const secondButton = el.querySelector("#second");
|
|
170
|
+
await elementUpdated(el);
|
|
171
|
+
expect(firstButton.hasAttribute("quiet")).to.be.true;
|
|
172
|
+
expect(firstButton.quiet).to.be.true;
|
|
173
|
+
expect(secondButton.hasAttribute("quiet")).to.be.true;
|
|
174
|
+
expect(secondButton.quiet).to.be.true;
|
|
175
|
+
});
|
|
176
|
+
it("applies `emphasized` attribute to slotted children with overlays", async () => {
|
|
177
|
+
const el = await fixture(html`
|
|
176
178
|
<emphasized-action-group>
|
|
177
179
|
<overlay-trigger slot="first">
|
|
178
180
|
<sp-action-button slot="trigger" id="first">
|
|
@@ -186,41 +188,41 @@ describe('ActionGroup', () => {
|
|
|
186
188
|
</overlay-trigger>
|
|
187
189
|
</emphasized-action-group>
|
|
188
190
|
`);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
const firstButton = el.querySelector("#first");
|
|
192
|
+
const secondButton = el.querySelector("#second");
|
|
193
|
+
await elementUpdated(el);
|
|
194
|
+
expect(firstButton.hasAttribute("emphasized")).to.be.true;
|
|
195
|
+
expect(firstButton.emphasized).to.be.true;
|
|
196
|
+
expect(secondButton.hasAttribute("emphasized")).to.be.true;
|
|
197
|
+
expect(secondButton.emphasized).to.be.true;
|
|
198
|
+
});
|
|
199
|
+
it('loads [selects="single"] action-group accessibly', async () => {
|
|
200
|
+
const el = await fixture(html`
|
|
199
201
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
200
202
|
<sp-action-button>First</sp-action-button>
|
|
201
203
|
<sp-action-button>Second</sp-action-button>
|
|
202
204
|
<sp-action-button>Third</sp-action-button>
|
|
203
205
|
</sp-action-group>
|
|
204
206
|
`);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
await elementUpdated(el);
|
|
208
|
+
await expect(el).to.be.accessible();
|
|
209
|
+
expect(el.getAttribute("aria-label")).to.equal("Selects Single Group");
|
|
210
|
+
expect(el.getAttribute("role")).to.equal("radiogroup");
|
|
211
|
+
expect(el.children[0].getAttribute("role")).to.equal("radio");
|
|
212
|
+
});
|
|
213
|
+
it('loads [selects="single"] action-group w/ selection accessibly', async () => {
|
|
214
|
+
const el = await fixture(html`
|
|
213
215
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
214
216
|
<sp-action-button>First</sp-action-button>
|
|
215
217
|
<sp-action-button>Second</sp-action-button>
|
|
216
218
|
<sp-action-button selected>Third</sp-action-button>
|
|
217
219
|
</sp-action-group>
|
|
218
220
|
`);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
await elementUpdated(el);
|
|
222
|
+
await expect(el).to.be.accessible();
|
|
223
|
+
});
|
|
224
|
+
it('loads [selects="multiple"] action-group accessibly', async () => {
|
|
225
|
+
const el = await fixture(html`
|
|
224
226
|
<sp-action-group
|
|
225
227
|
label="Selects Multiple Group"
|
|
226
228
|
selects="multiple"
|
|
@@ -230,14 +232,14 @@ describe('ActionGroup', () => {
|
|
|
230
232
|
<sp-action-button>Third</sp-action-button>
|
|
231
233
|
</sp-action-group>
|
|
232
234
|
`);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
await elementUpdated(el);
|
|
236
|
+
await expect(el).to.be.accessible();
|
|
237
|
+
expect(el.getAttribute("aria-label")).to.equal("Selects Multiple Group");
|
|
238
|
+
expect(el.getAttribute("role")).to.equal("group");
|
|
239
|
+
expect(el.children[0].getAttribute("role")).to.equal("checkbox");
|
|
240
|
+
});
|
|
241
|
+
it('loads [selects="multiple"] action-group w/ selection accessibly', async () => {
|
|
242
|
+
const el = await fixture(html`
|
|
241
243
|
<sp-action-group
|
|
242
244
|
label="Selects Multiple Group"
|
|
243
245
|
selects="multiple"
|
|
@@ -247,35 +249,35 @@ describe('ActionGroup', () => {
|
|
|
247
249
|
<sp-action-button selected>Third</sp-action-button>
|
|
248
250
|
</sp-action-group>
|
|
249
251
|
`);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
await elementUpdated(el);
|
|
253
|
+
await expect(el).to.be.accessible();
|
|
254
|
+
});
|
|
255
|
+
it('sets tab stop when [selects="single"] and the initial button is [disabled]', async () => {
|
|
256
|
+
const el = await fixture(html`
|
|
255
257
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
256
258
|
<sp-action-button disabled>First</sp-action-button>
|
|
257
259
|
<sp-action-button class="second">Second</sp-action-button>
|
|
258
260
|
<sp-action-button>Third</sp-action-button>
|
|
259
261
|
</sp-action-group>
|
|
260
262
|
`);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
263
|
+
const secondButton = el.querySelector(".second");
|
|
264
|
+
await elementUpdated(el);
|
|
265
|
+
expect(secondButton.hasAttribute("tabindex"));
|
|
266
|
+
expect(secondButton.getAttribute("tabindex")).to.equal("0");
|
|
267
|
+
});
|
|
268
|
+
it('surfaces [selects="single"] selection', async () => {
|
|
269
|
+
const el = await fixture(html`
|
|
268
270
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
269
271
|
<sp-action-button>First</sp-action-button>
|
|
270
272
|
<sp-action-button>Second</sp-action-button>
|
|
271
273
|
<sp-action-button selected>Third</sp-action-button>
|
|
272
274
|
</sp-action-group>
|
|
273
275
|
`);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
await elementUpdated(el);
|
|
277
|
+
expect(el.selected, '"Third" selected').to.deep.equal(["Third"]);
|
|
278
|
+
});
|
|
279
|
+
it('surfaces [selects="multiple"] selection', async () => {
|
|
280
|
+
const el = await fixture(html`
|
|
279
281
|
<sp-action-group
|
|
280
282
|
label="Selects Multiple Group"
|
|
281
283
|
selects="multiple"
|
|
@@ -285,29 +287,29 @@ describe('ActionGroup', () => {
|
|
|
285
287
|
<sp-action-button selected>Third</sp-action-button>
|
|
286
288
|
</sp-action-group>
|
|
287
289
|
`);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
await elementUpdated(el);
|
|
291
|
+
expect(el.selected, '"Second" and "Third" selected').to.deep.equal([
|
|
292
|
+
"Second",
|
|
293
|
+
"Third"
|
|
294
|
+
]);
|
|
295
|
+
});
|
|
296
|
+
it("does not select without [selects]", async () => {
|
|
297
|
+
const el = await fixture(html`
|
|
296
298
|
<sp-action-group label="No Selects Group">
|
|
297
299
|
<sp-action-button>First</sp-action-button>
|
|
298
300
|
<sp-action-button selected>Second</sp-action-button>
|
|
299
301
|
<sp-action-button class="third">Third</sp-action-button>
|
|
300
302
|
</sp-action-group>
|
|
301
303
|
`);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
304
|
+
const thirdElement = el.querySelector(".third");
|
|
305
|
+
await elementUpdated(el);
|
|
306
|
+
expect(el.selected.length).to.equal(1);
|
|
307
|
+
thirdElement.click();
|
|
308
|
+
await elementUpdated(el);
|
|
309
|
+
expect(el.selected.length).to.equal(1);
|
|
310
|
+
});
|
|
311
|
+
it('selects via `click` while [selects="single"]', async () => {
|
|
312
|
+
const el = await fixture(html`
|
|
311
313
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
312
314
|
<sp-action-button value="first">First</sp-action-button>
|
|
313
315
|
<sp-action-button value="second" selected>
|
|
@@ -318,17 +320,17 @@ describe('ActionGroup', () => {
|
|
|
318
320
|
</sp-action-button>
|
|
319
321
|
</sp-action-group>
|
|
320
322
|
`);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
323
|
+
const thirdElement = el.querySelector(".third");
|
|
324
|
+
await elementUpdated(el);
|
|
325
|
+
expect(el.selected.length).to.equal(1);
|
|
326
|
+
expect(el.selected.includes("second"));
|
|
327
|
+
thirdElement.click();
|
|
328
|
+
await elementUpdated(el);
|
|
329
|
+
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
330
|
+
await waitUntil(() => el.selected.length === 1 && el.selected.includes("third"), "Updates value of `selected`");
|
|
331
|
+
});
|
|
332
|
+
it('selects via `click` while [selects="multiple"] selection', async () => {
|
|
333
|
+
const el = await fixture(html`
|
|
332
334
|
<sp-action-group
|
|
333
335
|
label="Selects Multiple Group"
|
|
334
336
|
selects="multiple"
|
|
@@ -340,92 +342,90 @@ describe('ActionGroup', () => {
|
|
|
340
342
|
<sp-action-button class="third">Third</sp-action-button>
|
|
341
343
|
</sp-action-group>
|
|
342
344
|
`);
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
it('does not respond to clicks on itself', async () => {
|
|
360
|
-
const el = await fixture(html `
|
|
345
|
+
const firstElement = el.querySelector(".first");
|
|
346
|
+
const secondElement = el.querySelector(".second");
|
|
347
|
+
const thirdElement = el.querySelector(".third");
|
|
348
|
+
await elementUpdated(el);
|
|
349
|
+
expect(el.selected.length).to.equal(1);
|
|
350
|
+
expect(el.selected.includes("First"));
|
|
351
|
+
firstElement.click();
|
|
352
|
+
secondElement.click();
|
|
353
|
+
thirdElement.click();
|
|
354
|
+
await elementUpdated(el);
|
|
355
|
+
expect(secondElement.selected, "second child selected").to.be.true;
|
|
356
|
+
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
357
|
+
await waitUntil(() => el.selected.length === 2 && el.selected.includes("Second") && el.selected.includes("Third"), "Updates value of `selected`");
|
|
358
|
+
});
|
|
359
|
+
it("does not respond to clicks on itself", async () => {
|
|
360
|
+
const el = await fixture(html`
|
|
361
361
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
362
362
|
<sp-action-button>First</sp-action-button>
|
|
363
363
|
<sp-action-button>Second</sp-action-button>
|
|
364
364
|
<sp-action-button class="third">Third</sp-action-button>
|
|
365
365
|
</sp-action-group>
|
|
366
366
|
`);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
367
|
+
await elementUpdated(el);
|
|
368
|
+
expect(el.selected.length).to.equal(0);
|
|
369
|
+
el.click();
|
|
370
|
+
await elementUpdated(el);
|
|
371
|
+
expect(el.selected.length).to.equal(0);
|
|
372
|
+
});
|
|
373
|
+
it("selection can be prevented", async () => {
|
|
374
|
+
const el = await fixture(html`
|
|
375
375
|
<sp-action-group
|
|
376
376
|
label="Selects Single Group"
|
|
377
377
|
selects="single"
|
|
378
378
|
@change=${(event) => {
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
event.preventDefault();
|
|
380
|
+
}}
|
|
381
381
|
>
|
|
382
382
|
<sp-action-button>First</sp-action-button>
|
|
383
383
|
<sp-action-button>Second</sp-action-button>
|
|
384
384
|
<sp-action-button class="third">Third</sp-action-button>
|
|
385
385
|
</sp-action-group>
|
|
386
386
|
`);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
387
|
+
const thirdElement = el.querySelector(".third");
|
|
388
|
+
await elementUpdated(el);
|
|
389
|
+
expect(el.selected.length).to.equal(0);
|
|
390
|
+
thirdElement.click();
|
|
391
|
+
await elementUpdated(el);
|
|
392
|
+
expect(thirdElement.selected, "third child not selected").to.be.false;
|
|
393
|
+
expect(el.selected.length).to.equal(0);
|
|
394
|
+
});
|
|
395
|
+
it('selects user-passed value while [selects="single"]', async () => {
|
|
396
|
+
const el = await singleSelectedActionGroup(["first"]);
|
|
397
|
+
await elementUpdated(el);
|
|
398
|
+
expect(el.selected.length).to.equal(1);
|
|
399
|
+
const firstButton = el.querySelector(".first");
|
|
400
|
+
const secondButton = el.querySelector(".second");
|
|
401
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
402
|
+
expect(secondButton.selected, "second button not selected").to.be.false;
|
|
403
|
+
secondButton.click();
|
|
404
|
+
await elementUpdated(el);
|
|
405
|
+
expect(el.selected.length).to.equal(1);
|
|
406
|
+
expect(firstButton.selected, "first button not selected").to.be.false;
|
|
407
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
408
|
+
});
|
|
409
|
+
it('selects can be updated while [selects="single"]', async () => {
|
|
410
|
+
const el = await singleSelectedActionGroup(["first"]);
|
|
411
|
+
await elementUpdated(el);
|
|
412
|
+
expect(el.selected.length).to.equal(1);
|
|
413
|
+
const firstButton = el.querySelector(".first");
|
|
414
|
+
const secondButton = el.querySelector(".second");
|
|
415
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
416
|
+
expect(secondButton.selected, "second button not selected").to.be.false;
|
|
417
|
+
el.selected = ["second"];
|
|
418
|
+
await elementUpdated(el);
|
|
419
|
+
expect(el.selected.length).to.equal(1);
|
|
420
|
+
expect(firstButton.selected, "first button not selected").to.be.false;
|
|
421
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
422
|
+
});
|
|
423
|
+
it('selects user-passed value while [selects="multiple"]', async () => {
|
|
424
|
+
const el = await fixture(html`
|
|
425
425
|
<sp-action-group
|
|
426
426
|
label="Selects Multiple Group"
|
|
427
427
|
selects="multiple"
|
|
428
|
-
.selected=${[
|
|
428
|
+
.selected=${["first", "second"]}
|
|
429
429
|
>
|
|
430
430
|
<sp-action-button class="first" value="first">
|
|
431
431
|
First
|
|
@@ -438,33 +438,33 @@ describe('ActionGroup', () => {
|
|
|
438
438
|
</sp-action-button>
|
|
439
439
|
</sp-action-group>
|
|
440
440
|
`);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
441
|
+
await elementUpdated(el);
|
|
442
|
+
const firstButton = el.querySelector(".first");
|
|
443
|
+
const secondButton = el.querySelector(".second");
|
|
444
|
+
const thirdButton = el.querySelector(".third");
|
|
445
|
+
expect(el.selected.length).to.equal(2);
|
|
446
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
447
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
448
|
+
expect(thirdButton.selected, "third button not selected").to.be.false;
|
|
449
|
+
thirdButton.click();
|
|
450
|
+
await elementUpdated(el);
|
|
451
|
+
expect(el.selected.length).to.equal(3);
|
|
452
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
453
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
454
|
+
expect(thirdButton.selected, "third button selected").to.be.true;
|
|
455
|
+
firstButton.click();
|
|
456
|
+
await elementUpdated(el);
|
|
457
|
+
expect(el.selected.length).to.equal(2);
|
|
458
|
+
expect(firstButton.selected, "first button not selected").to.be.false;
|
|
459
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
460
|
+
expect(thirdButton.selected, "third button selected").to.be.true;
|
|
461
|
+
});
|
|
462
|
+
it('selects can be updated while [selects="multiple"]', async () => {
|
|
463
|
+
const el = await fixture(html`
|
|
464
464
|
<sp-action-group
|
|
465
465
|
label="Selects Multiple Group"
|
|
466
466
|
selects="multiple"
|
|
467
|
-
.selected=${[
|
|
467
|
+
.selected=${["first", "second"]}
|
|
468
468
|
>
|
|
469
469
|
<sp-action-button class="first" value="first">
|
|
470
470
|
First
|
|
@@ -477,55 +477,55 @@ describe('ActionGroup', () => {
|
|
|
477
477
|
</sp-action-button>
|
|
478
478
|
</sp-action-group>
|
|
479
479
|
`);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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
|
-
|
|
480
|
+
await elementUpdated(el);
|
|
481
|
+
const firstButton = el.querySelector(".first");
|
|
482
|
+
const secondButton = el.querySelector(".second");
|
|
483
|
+
const thirdButton = el.querySelector(".third");
|
|
484
|
+
expect(el.selected.length).to.equal(2);
|
|
485
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
486
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
487
|
+
expect(thirdButton.selected, "third button not selected").to.be.false;
|
|
488
|
+
el.selected = ["first", "second", "third"];
|
|
489
|
+
await elementUpdated(el);
|
|
490
|
+
expect(el.selected.length).to.equal(3);
|
|
491
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
492
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
493
|
+
expect(thirdButton.selected, "third button selected").to.be.true;
|
|
494
|
+
el.selected = ["second", "third"];
|
|
495
|
+
await elementUpdated(el);
|
|
496
|
+
expect(el.selected.length, JSON.stringify(el.selected)).to.equal(2);
|
|
497
|
+
expect(firstButton.selected, "first button not selected").to.be.false;
|
|
498
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
499
|
+
expect(thirdButton.selected, "third button selected").to.be.true;
|
|
500
|
+
});
|
|
501
|
+
it('selects multiple user-passed values while [selects="single"], but then proceeds with radio-button style functionality', async () => {
|
|
502
|
+
const el = await singleSelectedActionGroup(["first", "second"]);
|
|
503
|
+
await elementUpdated(el);
|
|
504
|
+
expect(el.selected.length).to.equal(2);
|
|
505
|
+
const firstButton = el.querySelector(".first");
|
|
506
|
+
const secondButton = el.querySelector(".second");
|
|
507
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
508
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
509
|
+
secondButton.click();
|
|
510
|
+
await elementUpdated(el);
|
|
511
|
+
expect(el.selected.length).to.equal(1);
|
|
512
|
+
expect(firstButton.selected, "first button selected").to.be.false;
|
|
513
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
514
|
+
});
|
|
515
|
+
it('only selects user-passed buttons if present in action-group while [selects="multiple"]', async () => {
|
|
516
|
+
const el = await multipleSelectedActionGroup(["second", "fourth"]);
|
|
517
|
+
await elementUpdated(el);
|
|
518
|
+
expect(el.selected.length).to.equal(1);
|
|
519
|
+
const secondButton = el.querySelector(".second");
|
|
520
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
521
|
+
const firstButton = el.querySelector(".first");
|
|
522
|
+
expect(firstButton.selected, "first button selected").to.be.false;
|
|
523
|
+
});
|
|
524
|
+
it("selects user-passed values with no .selects value, but does not allow interaction afterwards", async () => {
|
|
525
|
+
const el = await fixture(html`
|
|
526
526
|
<sp-action-group
|
|
527
527
|
label="Selects User-Chosen Buttons"
|
|
528
|
-
.selected=${[
|
|
528
|
+
.selected=${["first"]}
|
|
529
529
|
>
|
|
530
530
|
<sp-action-button value="first" class="first">
|
|
531
531
|
First
|
|
@@ -535,23 +535,23 @@ describe('ActionGroup', () => {
|
|
|
535
535
|
</sp-action-button>
|
|
536
536
|
</sp-action-group>
|
|
537
537
|
`);
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
538
|
+
await elementUpdated(el);
|
|
539
|
+
expect(el.selected.length).to.equal(1);
|
|
540
|
+
const firstButton = el.querySelector(".first");
|
|
541
|
+
const secondButton = el.querySelector(".second");
|
|
542
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
543
|
+
expect(secondButton.selected, "second button selected").to.be.false;
|
|
544
|
+
secondButton.click();
|
|
545
|
+
await elementUpdated(el);
|
|
546
|
+
expect(el.selected.length).to.equal(1);
|
|
547
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
548
|
+
expect(secondButton.selected, "second button selected").to.be.false;
|
|
549
|
+
});
|
|
550
|
+
it("selects multiple buttons if .selected is passed in, but does not allow further interaction afterwards", async () => {
|
|
551
|
+
const el = await fixture(html`
|
|
552
552
|
<sp-action-group
|
|
553
553
|
label="Selects User-Chosen Buttons"
|
|
554
|
-
.selected=${[
|
|
554
|
+
.selected=${["first", "second"]}
|
|
555
555
|
>
|
|
556
556
|
<sp-action-button class="first" value="first">
|
|
557
557
|
First
|
|
@@ -561,27 +561,27 @@ describe('ActionGroup', () => {
|
|
|
561
561
|
</sp-action-button>
|
|
562
562
|
</sp-action-group>
|
|
563
563
|
`);
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
564
|
+
await elementUpdated(el);
|
|
565
|
+
expect(el.selected.length).to.equal(2);
|
|
566
|
+
const firstButton = el.querySelector(".first");
|
|
567
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
568
|
+
const secondButton = el.querySelector(".second");
|
|
569
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
570
|
+
firstButton.click();
|
|
571
|
+
await elementUpdated(el);
|
|
572
|
+
expect(el.selected.length).to.equal(2);
|
|
573
|
+
expect(firstButton.selected, "first button selected").to.be.true;
|
|
574
|
+
expect(secondButton.selected, "second button selected").to.be.true;
|
|
575
|
+
});
|
|
576
|
+
it('will not change .selected state if event is prevented while [selects="multiple"]', async () => {
|
|
577
|
+
const el = await fixture(html`
|
|
578
578
|
<sp-action-group
|
|
579
579
|
label="Selects Multiple Group"
|
|
580
580
|
selects="multiple"
|
|
581
|
-
.selected=${[
|
|
581
|
+
.selected=${["first", "second"]}
|
|
582
582
|
@change=${(event) => {
|
|
583
|
-
|
|
584
|
-
|
|
583
|
+
event.preventDefault();
|
|
584
|
+
}}
|
|
585
585
|
>
|
|
586
586
|
<sp-action-button class="first" value="first">
|
|
587
587
|
First
|
|
@@ -594,34 +594,30 @@ describe('ActionGroup', () => {
|
|
|
594
594
|
</sp-action-button>
|
|
595
595
|
</sp-action-group>
|
|
596
596
|
`);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
.true;
|
|
615
|
-
});
|
|
616
|
-
it('will not change .selected state if event is prevented while [selects="single"]', async () => {
|
|
617
|
-
const el = await fixture(html `
|
|
597
|
+
const firstElement = el.querySelector(".first");
|
|
598
|
+
const secondElement = el.querySelector(".second");
|
|
599
|
+
const thirdElement = el.querySelector(".third");
|
|
600
|
+
await elementUpdated(el);
|
|
601
|
+
expect(el.selected.length).to.equal(2);
|
|
602
|
+
expect(firstElement.selected, "first child selected").to.be.true;
|
|
603
|
+
expect(secondElement.selected, "second child selected").to.be.true;
|
|
604
|
+
thirdElement.click();
|
|
605
|
+
await elementUpdated(el);
|
|
606
|
+
expect(thirdElement.selected, "third child not selected").to.be.false;
|
|
607
|
+
expect(el.selected.length).to.equal(2);
|
|
608
|
+
secondElement.click();
|
|
609
|
+
await elementUpdated(el);
|
|
610
|
+
expect(secondElement.selected, "second element still selected").to.be.true;
|
|
611
|
+
});
|
|
612
|
+
it('will not change .selected state if event is prevented while [selects="single"]', async () => {
|
|
613
|
+
const el = await fixture(html`
|
|
618
614
|
<sp-action-group
|
|
619
615
|
label="Selects Single Group"
|
|
620
616
|
selects="single"
|
|
621
|
-
.selected=${[
|
|
617
|
+
.selected=${["first"]}
|
|
622
618
|
@change=${(event) => {
|
|
623
|
-
|
|
624
|
-
|
|
619
|
+
event.preventDefault();
|
|
620
|
+
}}
|
|
625
621
|
>
|
|
626
622
|
<sp-action-button class="first" value="first">
|
|
627
623
|
First
|
|
@@ -631,31 +627,27 @@ describe('ActionGroup', () => {
|
|
|
631
627
|
</sp-action-button>
|
|
632
628
|
</sp-action-group>
|
|
633
629
|
`);
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
.true;
|
|
650
|
-
});
|
|
651
|
-
it('will not change .selected state if event is prevented while selects is undefined', async () => {
|
|
652
|
-
const el = await fixture(html `
|
|
630
|
+
const firstElement = el.querySelector(".first");
|
|
631
|
+
const secondElement = el.querySelector(".second");
|
|
632
|
+
await elementUpdated(el);
|
|
633
|
+
expect(el.selected.length).to.equal(1);
|
|
634
|
+
expect(firstElement.selected, "first child selected").to.be.true;
|
|
635
|
+
secondElement.click();
|
|
636
|
+
await elementUpdated(el);
|
|
637
|
+
expect(secondElement.selected, "second child not selected").to.be.false;
|
|
638
|
+
expect(el.selected.length).to.equal(1);
|
|
639
|
+
firstElement.click();
|
|
640
|
+
await elementUpdated(el);
|
|
641
|
+
expect(firstElement.selected, "first element still selected").to.be.true;
|
|
642
|
+
});
|
|
643
|
+
it("will not change .selected state if event is prevented while selects is undefined", async () => {
|
|
644
|
+
const el = await fixture(html`
|
|
653
645
|
<sp-action-group
|
|
654
646
|
label="Selects Single Group"
|
|
655
|
-
.selected=${[
|
|
647
|
+
.selected=${["first"]}
|
|
656
648
|
@change=${(event) => {
|
|
657
|
-
|
|
658
|
-
|
|
649
|
+
event.preventDefault();
|
|
650
|
+
}}
|
|
659
651
|
>
|
|
660
652
|
<sp-action-button class="first" value="first">
|
|
661
653
|
First
|
|
@@ -665,21 +657,19 @@ describe('ActionGroup', () => {
|
|
|
665
657
|
</sp-action-button>
|
|
666
658
|
</sp-action-group>
|
|
667
659
|
`);
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
it('will accept selected as a JSON string', async () => {
|
|
682
|
-
const el = await fixture(html `
|
|
660
|
+
const firstElement = el.querySelector(".first");
|
|
661
|
+
const secondElement = el.querySelector(".second");
|
|
662
|
+
await elementUpdated(el);
|
|
663
|
+
expect(el.selected.length).to.equal(1);
|
|
664
|
+
expect(firstElement.selected, "first child selected").to.be.true;
|
|
665
|
+
secondElement.click();
|
|
666
|
+
await elementUpdated(el);
|
|
667
|
+
expect(el.selected.length).to.equal(1);
|
|
668
|
+
expect(firstElement.selected, "first child selected").to.be.true;
|
|
669
|
+
expect(secondElement.selected, "second child not selected").to.be.false;
|
|
670
|
+
});
|
|
671
|
+
it("will accept selected as a JSON string", async () => {
|
|
672
|
+
const el = await fixture(html`
|
|
683
673
|
<sp-action-group
|
|
684
674
|
label="Selects Single Group"
|
|
685
675
|
selects="single"
|
|
@@ -693,60 +683,59 @@ describe('ActionGroup', () => {
|
|
|
693
683
|
</sp-action-button>
|
|
694
684
|
</sp-action-group>
|
|
695
685
|
`);
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
const el = await fixture(html `
|
|
686
|
+
await elementUpdated(el);
|
|
687
|
+
const firstElement = el.querySelector(".first");
|
|
688
|
+
const secondElement = el.querySelector(".second");
|
|
689
|
+
expect(el.selected.length).to.equal(1);
|
|
690
|
+
expect(firstElement.selected, "first child selected").to.be.true;
|
|
691
|
+
expect(secondElement.selected, "second child selected").to.be.false;
|
|
692
|
+
});
|
|
693
|
+
const acceptKeyboardInput = async (el) => {
|
|
694
|
+
const thirdElement = el.querySelector(".third");
|
|
695
|
+
await elementUpdated(el);
|
|
696
|
+
expect(el.selected.length).to.equal(1);
|
|
697
|
+
expect(el.selected[0]).to.equal("Second");
|
|
698
|
+
thirdElement.click();
|
|
699
|
+
await elementUpdated(el);
|
|
700
|
+
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
701
|
+
expect(el.selected.length).to.equal(1);
|
|
702
|
+
expect(el.selected[0]).to.equal("Third");
|
|
703
|
+
el.dispatchEvent(arrowRightEvent());
|
|
704
|
+
await sendKeys({ press: "Enter" });
|
|
705
|
+
await elementUpdated(el);
|
|
706
|
+
expect(el.selected.length).to.equal(1);
|
|
707
|
+
expect(el.selected[0]).to.equal("First");
|
|
708
|
+
el.dispatchEvent(arrowLeftEvent());
|
|
709
|
+
el.dispatchEvent(arrowUpEvent());
|
|
710
|
+
await sendKeys({ press: "Enter" });
|
|
711
|
+
expect(el.selected.length).to.equal(1);
|
|
712
|
+
expect(el.selected[0]).to.equal("Second");
|
|
713
|
+
el.dispatchEvent(endEvent());
|
|
714
|
+
await sendKeys({ press: "Enter" });
|
|
715
|
+
expect(el.selected.length).to.equal(1);
|
|
716
|
+
expect(el.selected[0]).to.equal("Third");
|
|
717
|
+
await sendKeys({ press: "Enter" });
|
|
718
|
+
el.dispatchEvent(homeEvent());
|
|
719
|
+
await sendKeys({ press: "Enter" });
|
|
720
|
+
expect(el.selected.length).to.equal(1);
|
|
721
|
+
expect(el.selected[0]).to.equal("First");
|
|
722
|
+
el.dispatchEvent(arrowDownEvent());
|
|
723
|
+
await sendKeys({ press: "Enter" });
|
|
724
|
+
expect(el.selected.length).to.equal(1);
|
|
725
|
+
expect(el.selected[0]).to.equal("Second");
|
|
726
|
+
};
|
|
727
|
+
it("accepts keybord input", async () => {
|
|
728
|
+
const el = await fixture(html`
|
|
740
729
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
741
730
|
<sp-action-button>First</sp-action-button>
|
|
742
731
|
<sp-action-button selected>Second</sp-action-button>
|
|
743
732
|
<sp-action-button class="third">Third</sp-action-button>
|
|
744
733
|
</sp-action-group>
|
|
745
734
|
`);
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
735
|
+
await acceptKeyboardInput(el);
|
|
736
|
+
});
|
|
737
|
+
it("accepts keybord input with tooltip", async () => {
|
|
738
|
+
const el = await fixture(html`
|
|
750
739
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
751
740
|
<overlay-trigger>
|
|
752
741
|
<sp-action-button slot="trigger">
|
|
@@ -772,10 +761,10 @@ describe('ActionGroup', () => {
|
|
|
772
761
|
</overlay-trigger>
|
|
773
762
|
</sp-action-group>
|
|
774
763
|
`);
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
764
|
+
await acceptKeyboardInput(el);
|
|
765
|
+
});
|
|
766
|
+
it('accepts keybord input when [dir="ltr"]', async () => {
|
|
767
|
+
const el = await fixture(html`
|
|
779
768
|
<sp-action-group
|
|
780
769
|
label="Selects Single Group"
|
|
781
770
|
selects="single"
|
|
@@ -786,23 +775,23 @@ describe('ActionGroup', () => {
|
|
|
786
775
|
<sp-action-button class="third">Third</sp-action-button>
|
|
787
776
|
</sp-action-group>
|
|
788
777
|
`);
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
778
|
+
const thirdElement = el.querySelector(".third");
|
|
779
|
+
await elementUpdated(el);
|
|
780
|
+
expect(el.selected.length).to.equal(0);
|
|
781
|
+
thirdElement.click();
|
|
782
|
+
await elementUpdated(el);
|
|
783
|
+
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
784
|
+
expect(el.selected.length).to.equal(1);
|
|
785
|
+
expect(el.selected[0]).to.equal("Third");
|
|
786
|
+
el.dispatchEvent(arrowRightEvent());
|
|
787
|
+
await sendKeys({ press: "Enter" });
|
|
788
|
+
await elementUpdated(el);
|
|
789
|
+
expect(el.selected.length).to.equal(1);
|
|
790
|
+
expect(el.selected[0]).to.equal("First");
|
|
791
|
+
el.dispatchEvent(arrowUpEvent());
|
|
792
|
+
await sendKeys({ press: "Enter" });
|
|
793
|
+
expect(el.selected.length).to.equal(1);
|
|
794
|
+
expect(el.selected[0]).to.equal("Third");
|
|
795
|
+
});
|
|
807
796
|
});
|
|
808
|
-
//# sourceMappingURL=action-group.test.js.map
|
|
797
|
+
//# sourceMappingURL=action-group.test.js.map
|