Skip to content

Commit

Permalink
test(menu-item): add token theming tests (#9420)
Browse files Browse the repository at this point in the history
**Related Issue:** #7180

## Summary
Add token theming tests for `menu-item`.
  • Loading branch information
Elijbet authored May 30, 2024
1 parent 52cdd12 commit 4677c4d
Showing 1 changed file with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { newE2EPage } from "@stencil/core/testing";
import { html } from "../../../support/formatting";
import { accessible, focusable, hidden, reflects, renders, t9n } from "../../tests/commonTests";
import { accessible, focusable, hidden, reflects, renders, t9n, themed } from "../../tests/commonTests";
import { getFocusedElementProp } from "../../tests/utils";
import { ComponentTestTokens } from "../../tests/commonTests/themed";
import { CSS } from "./resources";

describe("calcite-menu-item", () => {
describe("renders", () => {
Expand Down Expand Up @@ -116,3 +118,89 @@ describe("calcite-menu-item", () => {
expect(eventSpy).toHaveReceivedEventTimes(2);
});
});

describe("theme", () => {
const menuItemHtml = html`
<calcite-menu layout="vertical">
<calcite-menu-item text="Example submenu item 2" text-enabled href="https://esri.com">
<calcite-menu-item slot="submenu-item" text="Example submenu item 1" text-enabled></calcite-menu-item>
</calcite-menu-item>
</calcite-menu>
`;
const dropdownMenuItems = html`
<calcite-menu layout="horizontal">
<calcite-menu-item text="Example item" text-enabled icon-start="layer" icon-end="layer" breadcrumb open>
<calcite-menu-item slot="submenu-item" text="Example submenu item 1" text-enabled></calcite-menu-item>
<calcite-menu-item slot="submenu-item" text="Example submenu item 2" text-enabled href="https://esri.com">
<calcite-menu-item slot="submenu-item" text="Example submenu item 1" text-enabled></calcite-menu-item>
</calcite-menu-item>
</calcite-menu-item>
</calcite-menu>
`;
describe("default", () => {
const tokens: ComponentTestTokens = {
"--calcite-menu-item-action-background-color-active": {
shadowSelector: "calcite-action",
targetProp: "--calcite-action-background-color",
state: { press: { attribute: "class", value: CSS.dropdownAction } },
},
"--calcite-menu-item-action-background-color-hover": {
shadowSelector: "calcite-action",
targetProp: "--calcite-action-background-color",
state: "hover",
},
"--calcite-menu-item-action-background-color": {
shadowSelector: `calcite-action`,
targetProp: "--calcite-action-background-color",
},
"--calcite-menu-item-sub-menu-corner-radius": {
shadowSelector: `.dropdown--vertical`,
targetProp: "borderRadius",
},
"--calcite-menu-item-background-color": {
shadowSelector: `.${CSS.content}`,
targetProp: "backgroundColor",
},
"--calcite-menu-item-border-color": {
shadowSelector: `.${CSS.content}`,
targetProp: "borderColor",
},
};
themed(async () => {
const page = await newE2EPage();
await page.setContent(menuItemHtml);
await page.waitForChanges();
return { tag: "calcite-menu-item", page };
}, tokens);
});

describe("dropdownMenuItems", () => {
const tokens: ComponentTestTokens = {
"--calcite-menu-item-background-color": {
shadowSelector: `.${CSS.dropdownMenuItems}`,
targetProp: "backgroundColor",
},
"--calcite-menu-item-icon-color": {
shadowSelector: `.${CSS.container} .${CSS.icon}`,
targetProp: "--calcite-icon-color",
},
"--calcite-menu-item-text-color": {
shadowSelector: `.${CSS.content}`,
targetProp: "color",
},
"--calcite-menu-item-sub-menu-border-color": {
shadowSelector: `.${CSS.dropdownMenuItems}`,
targetProp: "borderColor",
},
};
themed(async () => {
const page = await newE2EPage();
await page.setContent(dropdownMenuItems);
const menuItem = await page.find("calcite-menu-item");
await menuItem.click();
await page.waitForChanges();
menuItem.setProperty("open", true);
return { tag: "calcite-menu-item", page };
}, tokens);
});
});

0 comments on commit 4677c4d

Please sign in to comment.