@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.
@@ -1,46 +1,48 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { elementUpdated, expect, fixture, html, waitUntil, } from '@open-wc/testing';
13
- import '@spectrum-web-components/action-button/sp-action-button.js';
14
- import { LitElement } from '@spectrum-web-components/base';
15
- import '@spectrum-web-components/overlay/overlay-trigger.js';
16
- import '@spectrum-web-components/tooltip/sp-tooltip.js';
17
- import { arrowDownEvent, arrowLeftEvent, arrowRightEvent, arrowUpEvent, endEvent, homeEvent, } from '../../../test/testing-helpers';
18
- import { sendKeys } from '@web/test-runner-commands';
19
- import '../sp-action-group.js';
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
- render() {
22
- return html `
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('quiet-action-group', QuietActionGroup);
32
+ customElements.define("quiet-action-group", QuietActionGroup);
31
33
  class EmphasizedActionGroup extends LitElement {
32
- render() {
33
- return html `
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('emphasized-action-group', EmphasizedActionGroup);
43
+ customElements.define("emphasized-action-group", EmphasizedActionGroup);
42
44
  async function singleSelectedActionGroup(selected) {
43
- const el = await fixture(html `
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
- return el;
59
+ return el;
58
60
  }
59
61
  async function multipleSelectedActionGroup(selected) {
60
- const el = await fixture(html `
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
- return el;
76
+ return el;
75
77
  }
76
- describe('ActionGroup', () => {
77
- it('loads empty action-group accessibly', async () => {
78
- const el = await fixture(html `
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
- await elementUpdated(el);
82
- await expect(el).to.be.accessible();
83
- });
84
- it('loads default action-group accessibly', async () => {
85
- const el = await fixture(html `
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
- await elementUpdated(el);
93
- await expect(el).to.be.accessible();
94
- expect(el.getAttribute('aria-label')).to.equal('Default Group');
95
- expect(el.hasAttribute('role')).to.be.false;
96
- expect(el.children[0].getAttribute('role')).to.equal('button');
97
- });
98
- it('applies `quiet` attribute to its children', async () => {
99
- const el = await fixture(html `
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
- const firstButton = el.querySelector('#first');
106
- const secondButton = el.querySelector('#second');
107
- await elementUpdated(el);
108
- expect(firstButton.hasAttribute('quiet')).to.be.true;
109
- expect(firstButton.quiet).to.be.true;
110
- expect(secondButton.hasAttribute('quiet')).to.be.true;
111
- expect(secondButton.quiet).to.be.true;
112
- });
113
- it('applies `quiet` attribute to its slotted children', async () => {
114
- const el = await fixture(html `
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
- const firstButton = el.querySelector('#first');
125
- const secondButton = el.querySelector('#second');
126
- await elementUpdated(el);
127
- expect(firstButton.hasAttribute('quiet')).to.be.true;
128
- expect(firstButton.quiet).to.be.true;
129
- expect(secondButton.hasAttribute('quiet')).to.be.true;
130
- expect(secondButton.quiet).to.be.true;
131
- });
132
- it('applies `emphasized` attribute to its slotted children', async () => {
133
- const el = await fixture(html `
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
- const firstButton = el.querySelector('#first');
144
- const secondButton = el.querySelector('#second');
145
- await elementUpdated(el);
146
- expect(firstButton.hasAttribute('emphasized')).to.be.true;
147
- expect(firstButton.emphasized).to.be.true;
148
- expect(secondButton.hasAttribute('emphasized')).to.be.true;
149
- expect(secondButton.emphasized).to.be.true;
150
- });
151
- it('applies `quiet` attribute to slotted children with overlays', async () => {
152
- const el = await fixture(html `
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
- const firstButton = el.querySelector('#first');
167
- const secondButton = el.querySelector('#second');
168
- await elementUpdated(el);
169
- expect(firstButton.hasAttribute('quiet')).to.be.true;
170
- expect(firstButton.quiet).to.be.true;
171
- expect(secondButton.hasAttribute('quiet')).to.be.true;
172
- expect(secondButton.quiet).to.be.true;
173
- });
174
- it('applies `emphasized` attribute to slotted children with overlays', async () => {
175
- const el = await fixture(html `
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
- const firstButton = el.querySelector('#first');
190
- const secondButton = el.querySelector('#second');
191
- await elementUpdated(el);
192
- expect(firstButton.hasAttribute('emphasized')).to.be.true;
193
- expect(firstButton.emphasized).to.be.true;
194
- expect(secondButton.hasAttribute('emphasized')).to.be.true;
195
- expect(secondButton.emphasized).to.be.true;
196
- });
197
- it('loads [selects="single"] action-group accessibly', async () => {
198
- const el = await fixture(html `
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
- await elementUpdated(el);
206
- await expect(el).to.be.accessible();
207
- expect(el.getAttribute('aria-label')).to.equal('Selects Single Group');
208
- expect(el.getAttribute('role')).to.equal('radiogroup');
209
- expect(el.children[0].getAttribute('role')).to.equal('radio');
210
- });
211
- it('loads [selects="single"] action-group w/ selection accessibly', async () => {
212
- const el = await fixture(html `
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
- await elementUpdated(el);
220
- await expect(el).to.be.accessible();
221
- });
222
- it('loads [selects="multiple"] action-group accessibly', async () => {
223
- const el = await fixture(html `
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
- await elementUpdated(el);
234
- await expect(el).to.be.accessible();
235
- expect(el.getAttribute('aria-label')).to.equal('Selects Multiple Group');
236
- expect(el.getAttribute('role')).to.equal('group');
237
- expect(el.children[0].getAttribute('role')).to.equal('checkbox');
238
- });
239
- it('loads [selects="multiple"] action-group w/ selection accessibly', async () => {
240
- const el = await fixture(html `
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
- await elementUpdated(el);
251
- await expect(el).to.be.accessible();
252
- });
253
- it('sets tab stop when [selects="single"] and the initial button is [disabled]', async () => {
254
- const el = await fixture(html `
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
- const secondButton = el.querySelector('.second');
262
- await elementUpdated(el);
263
- expect(secondButton.hasAttribute('tabindex'));
264
- expect(secondButton.getAttribute('tabindex')).to.equal('0');
265
- });
266
- it('surfaces [selects="single"] selection', async () => {
267
- const el = await fixture(html `
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
- await elementUpdated(el);
275
- expect(el.selected, '"Third" selected').to.deep.equal(['Third']);
276
- });
277
- it('surfaces [selects="multiple"] selection', async () => {
278
- const el = await fixture(html `
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
- await elementUpdated(el);
289
- expect(el.selected, '"Second" and "Third" selected').to.deep.equal([
290
- 'Second',
291
- 'Third',
292
- ]);
293
- });
294
- it('does not select without [selects]', async () => {
295
- const el = await fixture(html `
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
- const thirdElement = el.querySelector('.third');
303
- await elementUpdated(el);
304
- expect(el.selected.length).to.equal(1);
305
- thirdElement.click();
306
- await elementUpdated(el);
307
- expect(el.selected.length).to.equal(1);
308
- });
309
- it('selects via `click` while [selects="single"]', async () => {
310
- const el = await fixture(html `
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
- const thirdElement = el.querySelector('.third');
322
- await elementUpdated(el);
323
- expect(el.selected.length).to.equal(1);
324
- expect(el.selected.includes('second'));
325
- thirdElement.click();
326
- await elementUpdated(el);
327
- expect(thirdElement.selected, 'third child selected').to.be.true;
328
- await waitUntil(() => el.selected.length === 1 && el.selected.includes('third'), 'Updates value of `selected`');
329
- });
330
- it('selects via `click` while [selects="multiple"] selection', async () => {
331
- const el = await fixture(html `
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
- const firstElement = el.querySelector('.first');
344
- const secondElement = el.querySelector('.second');
345
- const thirdElement = el.querySelector('.third');
346
- await elementUpdated(el);
347
- expect(el.selected.length).to.equal(1);
348
- expect(el.selected.includes('First'));
349
- firstElement.click();
350
- secondElement.click();
351
- thirdElement.click();
352
- await elementUpdated(el);
353
- expect(secondElement.selected, 'second child selected').to.be.true;
354
- expect(thirdElement.selected, 'third child selected').to.be.true;
355
- await waitUntil(() => el.selected.length === 2 &&
356
- el.selected.includes('Second') &&
357
- 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 `
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
- 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 `
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
- event.preventDefault();
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
- 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 `
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=${['first', 'second']}
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
- 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 `
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=${['first', 'second']}
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
- 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 `
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=${['first']}
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
- 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 `
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=${['first', 'second']}
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
- 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 `
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=${['first', 'second']}
581
+ .selected=${["first", "second"]}
582
582
  @change=${(event) => {
583
- event.preventDefault();
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
- const firstElement = el.querySelector('.first');
598
- const secondElement = el.querySelector('.second');
599
- const thirdElement = el.querySelector('.third');
600
- // checking if the first and second are selected
601
- await elementUpdated(el);
602
- expect(el.selected.length).to.equal(2);
603
- expect(firstElement.selected, 'first child selected').to.be.true;
604
- expect(secondElement.selected, 'second child selected').to.be.true;
605
- // making sure third element isn't selected
606
- thirdElement.click();
607
- await elementUpdated(el);
608
- expect(thirdElement.selected, 'third child not selected').to.be.false;
609
- expect(el.selected.length).to.equal(2);
610
- // making sure already-selected elements are not de-selected
611
- secondElement.click();
612
- await elementUpdated(el);
613
- expect(secondElement.selected, 'second element still selected').to.be
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=${['first']}
617
+ .selected=${["first"]}
622
618
  @change=${(event) => {
623
- event.preventDefault();
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
- const firstElement = el.querySelector('.first');
635
- const secondElement = el.querySelector('.second');
636
- // checking if the first element is selected
637
- await elementUpdated(el);
638
- expect(el.selected.length).to.equal(1);
639
- expect(firstElement.selected, 'first child selected').to.be.true;
640
- // making sure third element isn't selected
641
- secondElement.click();
642
- await elementUpdated(el);
643
- expect(secondElement.selected, 'second child not selected').to.be.false;
644
- expect(el.selected.length).to.equal(1);
645
- // making sure already-selected elements are not de-selected
646
- firstElement.click();
647
- await elementUpdated(el);
648
- expect(firstElement.selected, 'first element still selected').to.be
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=${['first']}
647
+ .selected=${["first"]}
656
648
  @change=${(event) => {
657
- event.preventDefault();
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
- const firstElement = el.querySelector('.first');
669
- const secondElement = el.querySelector('.second');
670
- // checking if the first element is selected
671
- await elementUpdated(el);
672
- expect(el.selected.length).to.equal(1);
673
- expect(firstElement.selected, 'first child selected').to.be.true;
674
- secondElement.click();
675
- await elementUpdated(el);
676
- // state should be exactly the same
677
- expect(el.selected.length).to.equal(1);
678
- expect(firstElement.selected, 'first child selected').to.be.true;
679
- expect(secondElement.selected, 'second child not selected').to.be.false;
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
- // checking if the first element is selected
697
- await elementUpdated(el);
698
- const firstElement = el.querySelector('.first');
699
- const secondElement = el.querySelector('.second');
700
- expect(el.selected.length).to.equal(1);
701
- expect(firstElement.selected, 'first child selected').to.be.true;
702
- expect(secondElement.selected, 'second child selected').to.be.false;
703
- });
704
- const acceptKeyboardInput = async (el) => {
705
- const thirdElement = el.querySelector('.third');
706
- await elementUpdated(el);
707
- expect(el.selected.length).to.equal(1);
708
- expect(el.selected[0]).to.equal('Second');
709
- thirdElement.click();
710
- await elementUpdated(el);
711
- expect(thirdElement.selected, 'third child selected').to.be.true;
712
- expect(el.selected.length).to.equal(1);
713
- expect(el.selected[0]).to.equal('Third');
714
- el.dispatchEvent(arrowRightEvent());
715
- await sendKeys({ press: 'Enter' });
716
- await elementUpdated(el);
717
- expect(el.selected.length).to.equal(1);
718
- expect(el.selected[0]).to.equal('First');
719
- el.dispatchEvent(arrowLeftEvent());
720
- el.dispatchEvent(arrowUpEvent());
721
- await sendKeys({ press: 'Enter' });
722
- expect(el.selected.length).to.equal(1);
723
- expect(el.selected[0]).to.equal('Second');
724
- el.dispatchEvent(endEvent());
725
- await sendKeys({ press: 'Enter' });
726
- expect(el.selected.length).to.equal(1);
727
- expect(el.selected[0]).to.equal('Third');
728
- await sendKeys({ press: 'Enter' });
729
- el.dispatchEvent(homeEvent());
730
- await sendKeys({ press: 'Enter' });
731
- expect(el.selected.length).to.equal(1);
732
- expect(el.selected[0]).to.equal('First');
733
- el.dispatchEvent(arrowDownEvent());
734
- await sendKeys({ press: 'Enter' });
735
- expect(el.selected.length).to.equal(1);
736
- expect(el.selected[0]).to.equal('Second');
737
- };
738
- it('accepts keybord input', async () => {
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
- await acceptKeyboardInput(el);
747
- });
748
- it('accepts keybord input with tooltip', async () => {
749
- const el = await fixture(html `
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
- await acceptKeyboardInput(el);
776
- });
777
- it('accepts keybord input when [dir="ltr"]', async () => {
778
- const el = await fixture(html `
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
- const thirdElement = el.querySelector('.third');
790
- await elementUpdated(el);
791
- expect(el.selected.length).to.equal(0);
792
- thirdElement.click();
793
- await elementUpdated(el);
794
- expect(thirdElement.selected, 'third child selected').to.be.true;
795
- expect(el.selected.length).to.equal(1);
796
- expect(el.selected[0]).to.equal('Third');
797
- el.dispatchEvent(arrowRightEvent());
798
- await sendKeys({ press: 'Enter' });
799
- await elementUpdated(el);
800
- expect(el.selected.length).to.equal(1);
801
- expect(el.selected[0]).to.equal('First');
802
- el.dispatchEvent(arrowUpEvent());
803
- await sendKeys({ press: 'Enter' });
804
- expect(el.selected.length).to.equal(1);
805
- expect(el.selected[0]).to.equal('Third');
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