|
1 |
| -import { assert, elementUpdated, expect, fixture, waitUntil } from "@open-wc/testing"; |
| 1 | +import { assert, expect, fixture, waitUntil } from "@open-wc/testing"; |
2 | 2 | import { sendKeys } from "@web/test-runner-commands";
|
3 | 3 | import { html } from "lit";
|
4 | 4 | import sinon from "sinon";
|
@@ -336,6 +336,26 @@ describe("single select combobox", () => {
|
336 | 336 | await waitUntil(() => el.shadowRoot?.querySelector("sgds-input")?.value === "Apple");
|
337 | 337 | expect(el.value).to.equal("option1");
|
338 | 338 | });
|
| 339 | + |
| 340 | + it("Keyboard arrowDown and enter populates the input with badge", async () => { |
| 341 | + const el = await fixture<SgdsComboBox>( |
| 342 | + html`<sgds-combo-box |
| 343 | + .menuList=${[ |
| 344 | + { label: "Apple", value: "option1" }, |
| 345 | + { label: "Apricot", value: "option2" }, |
| 346 | + { label: "Dur", value: "option3" } |
| 347 | + ]} |
| 348 | + ></sgds-combo-box>` |
| 349 | + ); |
| 350 | + |
| 351 | + const input = el.shadowRoot?.querySelector("sgds-input") as SgdsInput; |
| 352 | + input.focus(); |
| 353 | + await sendKeys({ press: "ArrowDown" }); |
| 354 | + await sendKeys({ press: "Enter" }); |
| 355 | + await el.updateComplete; |
| 356 | + expect(el.value).to.equal("option1"); |
| 357 | + expect(el.shadowRoot?.querySelector("sgds-input")?.value).to.equal("Apple"); |
| 358 | + }); |
339 | 359 | });
|
340 | 360 |
|
341 | 361 | describe("multi select combobox", () => {
|
@@ -463,21 +483,44 @@ describe("multi select combobox", () => {
|
463 | 483 | const durItem = el.shadowRoot?.querySelector("sgds-combo-box-item[value='option3']") as SgdsComboBoxItem;
|
464 | 484 | expect(durItem.active).to.be.false;
|
465 | 485 | });
|
| 486 | + it("Keyboard arrowDown and enter populates the input with badge", async () => { |
| 487 | + const el = await fixture<SgdsComboBox>( |
| 488 | + html`<sgds-combo-box |
| 489 | + multiSelect |
| 490 | + .menuList=${[ |
| 491 | + { label: "Apple", value: "option1" }, |
| 492 | + { label: "Apricot", value: "option2" }, |
| 493 | + { label: "Dur", value: "option3" } |
| 494 | + ]} |
| 495 | + ></sgds-combo-box>` |
| 496 | + ); |
| 497 | + |
| 498 | + const input = el.shadowRoot?.querySelector("sgds-input") as SgdsInput; |
| 499 | + input.focus(); |
| 500 | + await sendKeys({ press: "ArrowDown" }); |
| 501 | + await sendKeys({ press: "Enter" }); |
| 502 | + await el.updateComplete; |
| 503 | + expect(el.value).to.equal("option1"); |
| 504 | + const badge = input.shadowRoot?.querySelector("sgds-badge") as SgdsBadge; |
| 505 | + expect(badge.innerText).to.equal("Apple"); |
| 506 | + }); |
466 | 507 | });
|
467 | 508 |
|
468 | 509 | // UT scenarios
|
469 | 510 | // Single Select
|
470 | 511 | // 1. when initial value is specified, input is populated, item is active (DONE)
|
471 | 512 | // 2. When invalid displayValue is written, it should clear the input after losing focus (DONE)
|
472 |
| -// 3. When input value matches an item, item menu is shown and focused . On enter populates the input |
| 513 | +// 3. When input value matches an item, item menu is shown and focused . On enter populates the input (??? clarify with andy) |
473 | 514 | // 4. When input is cleared, the active item is no longer active (DONE)
|
474 | 515 | // 5. When a selection is made and input is blurred. The value of input or displayValue will sync with the menu selected item regardless of the value (DONE)
|
475 | 516 | // 6. If a purposeful selection is not made through enter or click, input is blurred. the displayValue clears regardless if value match anot (DONE)
|
| 517 | +// 7. Keyboard ArrowDown and Enter populates the input with value (DONE) |
476 | 518 |
|
477 | 519 | // UT scenarios
|
478 | 520 | // Multi Select
|
479 | 521 | // 1. when initial value is specified, input is populated, item is checked and active, badge is in input (DONE)
|
480 | 522 | // 2. When invalid displayValue is written, it should clear the input after losing focus (DONE)
|
481 |
| -// 3. When input value matches an item, item menu is shown and focused . On enter populates the input |
| 523 | +// 3. When input value matches an item, item menu is shown and focused . On enter populates the input (??? clarify with andy) |
482 | 524 | // 4. If a purposeful selection is not made through enter or click, input is blurred. the displayValue clears regardless if value match anot (DONE)
|
483 | 525 | // 5. When a badge is cancelled, it syncs with the removal actie item in the menu (DONE)
|
| 526 | +// 6. Keyboard arrowdown and enter populates the input with badge (DONE) |
0 commit comments