Skip to content

Commit

Permalink
test(select): add missed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Enes5519 committed Jan 28, 2025
1 parent b884bbd commit 9b6a67b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/select/bl-select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe("bl-select", () => {

const selectedOptions = el.shadowRoot?.querySelector<HTMLUListElement>(".selected-options");

expect(selectedOptions?.children[0].children[0]).to.equal("<bl-icon name=\"info\"></bl-icon>");
expect(selectedOptions?.children[0].children[0].outerHTML).to.equal("<bl-icon name=\"info\"></bl-icon>");
});
it("should open select menu", async () => {
const el = await fixture<BlSelect>(html`<bl-select><bl-select-option value="1">Option 1</bl-select-option></bl-select>`);
Expand Down
12 changes: 11 additions & 1 deletion src/components/select/option/bl-select-option.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, elementUpdated, fixture, expect, html, oneEvent } from "@open-wc/testing";
import { assert, elementUpdated, expect, fixture, html, oneEvent } from "@open-wc/testing";
import { sendKeys } from "@web/test-runner-commands";
import BlSelectOption from "./bl-select-option";

Expand All @@ -15,6 +15,8 @@ describe("bl-select", () => {
expect(el).shadowDom.equal(
`<div class="option-container">
<div class="focus-target single-option" role="option" aria-selected="false">
<slot name="icon">
</slot>
<slot>
</slot>
</div>
Expand All @@ -41,6 +43,14 @@ describe("bl-select", () => {
);
});

it("should rendered with custom icon", async () => {
const el = await fixture<BlSelectOption>(html`<bl-select-option><bl-icon slot="icon" name="info"></bl-icon></bl-select-option>`);

const iconSlot = el.shadowRoot!.querySelector<HTMLSlotElement>("slot[name=icon]")!;

expect(iconSlot.assignedElements()).deep.equal([el.querySelector("bl-icon")]);
});

it("should have aria-selected attribute set to true if the option is selected", async function () {
const el = await fixture<BlSelectOption>(
html`<bl-select-option value="basketball" selected>Basketball</bl-select-option>`
Expand Down

0 comments on commit 9b6a67b

Please sign in to comment.