Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(meter): Add token theming tests #9357

Merged
Merged
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
62 changes: 61 additions & 1 deletion packages/calcite-components/src/components/meter/meter.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { newE2EPage } from "@stencil/core/testing";
import { html } from "../../../support/formatting";
import { accessible, renders, hidden, defaults, reflects } from "../../tests/commonTests";
import { accessible, renders, hidden, defaults, reflects, themed } from "../../tests/commonTests";
import { ComponentTestTokens } from "../../tests/commonTests/themed";
import { CSS } from "./resources";

describe("calcite-meter", () => {
describe("renders", () => {
Expand Down Expand Up @@ -97,6 +99,64 @@ describe("calcite-meter", () => {
accessible(`<calcite-meter label="A great meter"></calcite-meter>`);
});

describe("theme", () => {
const meterHtml = html`<calcite-meter
group-separator
unit-label="GB"
value-label
range-labels
min="0"
max="12400"
low="4600"
high="7600"
value="-2200"
value-label-type="units"
></calcite-meter>`;

describe("default", () => {
const tokens: ComponentTestTokens = {
"--calcite-meter-background-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "backgroundColor",
},
"--calcite-meter-border-color": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderColor",
},
"--calcite-meter-corner-radius": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderRadius",
},
"--calcite-meter-shadow": {
targetProp: "boxShadow",
shadowSelector: `.${CSS.container}`,
},
"--calcite-meter-fill-color": {
shadowSelector: `.${CSS.fill}`,
targetProp: "backgroundColor",
},
"--calcite-meter-range-text-color": {
shadowSelector: `.${CSS.labelRange}`,
targetProp: "color",
},
"--calcite-meter-value-text-color": {
shadowSelector: `.${CSS.labelValue}`,
targetProp: "color",
},
};
themed(meterHtml, tokens);
});
describe("corner-radius-fill", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a nice enhancement to accept an array for shadowSelector - in this case I want to test that the css property is applied to two elements @alisonailea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supported (see example). 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice - will update.

const tokens: ComponentTestTokens = {
"--calcite-meter-corner-radius": {
shadowSelector: `.${CSS.fill}`,
targetProp: "borderRadius",
},
};
themed(meterHtml, tokens);
});
});

describe("correctly sets range and value properties", () => {
it("correctly sets range and value properties if not present", async () => {
const page = await newE2EPage({
Expand Down