Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { h } from "@arcgis/lumina";
import { describe } from "vitest";
import { mount } from "@arcgis/lumina-compiler/testing";
import {
Expand All @@ -8,8 +9,9 @@ import {
renders,
slots,
t9n,
themed,
} from "../../tests/commonTests/browser";
import { SLOTS } from "./resources";
import { SLOTS, CSS } from "./resources";

describe("defaults", () => {
defaults(
Expand Down Expand Up @@ -62,3 +64,78 @@ describe("is focusable", () => {
describe("translation support", () => {
t9n(() => mount("calcite-accordion-item"));
});

describe("themed", () => {
describe("default", () => {
themed(
() =>
mount(
<calcite-accordion-item
appearance="solid"
description="Description"
expanded
heading="Heading"
icon-end="home"
icon-start="home"
>
content
</calcite-accordion-item>,
),
{
"--calcite-accordion-item-content-space": {
targetProp: "padding",
shadowSelector: `.${CSS.content}`,
},
"--calcite-accordion-item-header-background-color": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
},
"--calcite-accordion-item-header-background-color-hover": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
state: "hover",
},
"--calcite-accordion-item-header-background-color-press": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
state: { press: `calcite-accordion-item .${CSS.header}` },
},
"--calcite-accordion-item-heading-text-color": {
shadowSelector: `.${CSS.headerContent}`,
targetProp: "color",
},
},
);
});

describe("icons", () => {
themed(
() =>
mount(
<calcite-accordion-item
description="Description"
expanded
heading="Heading"
icon-end="home"
icon-start="home"
>
content
</calcite-accordion-item>,
),
{
"--calcite-accordion-item-start-icon-color": {
shadowSelector: `.${CSS.iconStart}`,
targetProp: "color",
},
"--calcite-accordion-item-end-icon-color": {
shadowSelector: `.${CSS.iconEnd}`,
targetProp: "color",
},
"--calcite-accordion-item-expand-icon-color": {
shadowSelector: `.${CSS.expandIcon}`,
targetProp: "color",
},
},
);
});
});
Original file line number Diff line number Diff line change
@@ -1,167 +1,13 @@
import { newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
import { describe, expect, it } from "vitest";
import { accessible, themed } from "../../tests/commonTests";
import { accessible } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { CSS, IDS } from "./resources";

describe("accessible", () => {
accessible(`<calcite-accordion-item heading="My Heading"></calcite-accordion-item>`);
});

describe("theme", () => {
describe("default", () => {
themed(
html`<calcite-accordion-item
expanded
heading="Heading"
description="Description"
icon-start="home"
icon-end="home"
appearance="solid"
>content</calcite-accordion-item
>`,
{
"--calcite-accordion-item-content-space": {
targetProp: "padding",
shadowSelector: `.${CSS.content}`,
},
"--calcite-accordion-item-header-background-color": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
},
"--calcite-accordion-item-header-background-color-hover": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
state: "hover",
},
"--calcite-accordion-item-header-background-color-press": {
targetProp: "backgroundColor",
shadowSelector: `.${CSS.header}`,
state: { press: `calcite-accordion-item >>> .${CSS.header}` },
},
"--calcite-accordion-item-heading-text-color": {
shadowSelector: `.${CSS.headerContent}`,
targetProp: "color",
},
},
);
});
describe("icons", () => {
themed(
html`<calcite-accordion-item
heading="Heading"
description="Description"
icon-start="home"
icon-end="home"
expanded
>content</calcite-accordion-item
>`,
{
"--calcite-accordion-item-start-icon-color": {
shadowSelector: `.${CSS.iconStart}`,
targetProp: "color",
},
"--calcite-accordion-item-end-icon-color": {
shadowSelector: `.${CSS.iconEnd}`,
targetProp: "color",
},
"--calcite-accordion-item-expand-icon-color": {
shadowSelector: `.${CSS.expandIcon}`,
targetProp: "color",
},
},
);
});
describe("deprecated", () => {
describe("default", async () => {
themed(
html`<calcite-accordion-item heading="Heading" description="Description" icon-start="home" icon-end="home"
>content</calcite-accordion-item
>`,
{
"--calcite-accordion-item-text-color": [
{
targetProp: "color",
},
{
targetProp: "color",
shadowSelector: `.${CSS.expandIcon}`,
},
],
"--calcite-accordion-item-text-color-hover": [
{
targetProp: "color",
shadowSelector: `.${CSS.heading}`,
},
],
"--calcite-accordion-item-background-color": {
targetProp: "backgroundColor",
},
"--calcite-accordion-border-color": [
{
shadowSelector: `.${CSS.header}`,
targetProp: "borderColor",
},
{
shadowSelector: `.${CSS.content}`,
targetProp: "borderColor",
},
],
"--calcite-accordion-item-icon-color": [
{
shadowSelector: `.${CSS.iconStart}`,
targetProp: "color",
},
{
shadowSelector: `.${CSS.iconEnd}`,
targetProp: "color",
},
],
"--calcite-ui-icon-color": [
{
shadowSelector: `.${CSS.iconStart}`,
targetProp: "color",
},
{
shadowSelector: `.${CSS.iconEnd}`,
targetProp: "color",
},
],
},
);
});
describe("expanded", async () => {
themed(
html`<calcite-accordion-item
expanded
heading="Heading"
description="Description"
icon-start="home"
icon-end="home"
>content</calcite-accordion-item
>`,
{
"--calcite-accordion-item-text-color-hover": [
{
targetProp: "color",
shadowSelector: `.${CSS.expandIcon}`,
},
{
targetProp: "color",
shadowSelector: `.${CSS.description}`,
},
],
"--calcite-accordion-item-heading-text-color": {
selector: "calcite-accordion-item",
shadowSelector: `.${CSS.heading}`,
targetProp: "color",
},
},
);
});
});
});

it("properly uses ARIA and types", async () => {
// this test covers a11y relationships not reported by axe-core/accessible test helper

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe } from "vitest";
import { mount } from "@arcgis/lumina-compiler/testing";
import { defaults, reflects, hidden, renders } from "../../tests/commonTests/browser";
import { defaults, reflects, hidden, renders, themed } from "../../tests/commonTests/browser";
import { CSS as ACCORDION_ITEM_CSS } from "../accordion-item/resources";
import { CSS } from "./resources";

describe("defaults", () => {
defaults(
Expand Down Expand Up @@ -65,3 +67,66 @@ describe("honors hidden attribute", () => {
describe("renders", () => {
renders(() => mount("calcite-accordion"), { display: "block" });
});

describe("themed", () => {
themed(() => mount(`<calcite-accordion>${accordionContent}</calcite-accordion>`), {
"--calcite-accordion-background-color": [
{
shadowSelector: `.${CSS.accordion}`,
targetProp: "backgroundColor",
selector: "calcite-accordion",
},
{
targetProp: "backgroundColor",
selector: "calcite-accordion-item",
},
],
"--calcite-accordion-border-color": [
{
shadowSelector: `.${CSS.accordion}`,
targetProp: "borderColor",
selector: "calcite-accordion",
},
{
shadowSelector: `.${ACCORDION_ITEM_CSS.header}`,
targetProp: "borderColor",
selector: "calcite-accordion-item",
},
{
shadowSelector: `.${ACCORDION_ITEM_CSS.content}`,
targetProp: "borderColor",
selector: "calcite-accordion-item",
},
],
"--calcite-accordion-text-color": [
{
targetProp: "color",
selector: "calcite-accordion-item",
},
{
targetProp: "color",
shadowSelector: `.${ACCORDION_ITEM_CSS.headerContent}`,
selector: "calcite-accordion-item",
},
],
"--calcite-accordion-text-color-hover": [
{
selector: "calcite-accordion-item[expanded]",
shadowSelector: `.${ACCORDION_ITEM_CSS.expandIcon}`,
targetProp: "color",
},
{
selector: "calcite-accordion-item[expanded]",
shadowSelector: `.${ACCORDION_ITEM_CSS.description}`,
targetProp: "color",
},
],
"--calcite-accordion-item-heading-text-color": [
{
selector: "calcite-accordion-item",
shadowSelector: `.${ACCORDION_ITEM_CSS.heading}`,
targetProp: "color",
},
],
});
});
Loading
Loading