Skip to content

Commit

Permalink
test(progress): add component token E2E tests (#9605)
Browse files Browse the repository at this point in the history
**Related Issue:** #7180

## Summary

✨🧪✨
  • Loading branch information
jcfranco committed Jun 18, 2024
1 parent c4490a7 commit 37c26d5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { accessible, hidden, renders } from "../../tests/commonTests";
import { accessible, hidden, renders, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { CSS } from "./resources";

describe("calcite-progress", () => {
describe("renders", () => {
Expand All @@ -16,4 +18,28 @@ describe("calcite-progress", () => {
describe("accessible with value", () => {
accessible(`<calcite-progress value="50" type="indeterminate" text="percentage"></calcite-progress>`);
});

describe("theme", () => {
describe("default", () => {
themed("calcite-progress", {
"--calcite-progress-background-color": {
shadowSelector: `.${CSS.track}`,
targetProp: "backgroundColor",
},
"--calcite-progress-fill-color": {
shadowSelector: `.${CSS.bar}`,
targetProp: "backgroundColor",
},
});
});

describe("indeterminate", () => {
themed(html`<calcite-progress value="50" type="indeterminate" text="percentage"></calcite-progress>`, {
"--calcite-progress-text-color": {
shadowSelector: `.${CSS.text}`,
targetProp: "color",
},
});
});
});
});
10 changes: 6 additions & 4 deletions packages/calcite-components/src/components/progress/progress.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, Element, h, Prop, VNode } from "@stencil/core";
import { getElementDir } from "../../utils/dom";
import { CSS_UTILITY } from "../../utils/resources";
import { CSS } from "./resources";

@Component({
tag: "calcite-progress",
styleUrl: "progress.scss",
Expand Down Expand Up @@ -41,13 +43,13 @@ export class Progress {
aria-valuenow={this.value}
role="progressbar"
>
<div class="track">
<div class={CSS.track}>
<div
class={{
bar: true,
indeterminate: this.type === "indeterminate",
[CSS.bar]: true,
[CSS.indeterminate]: this.type === "indeterminate",
[CSS_UTILITY.rtl]: dir === "rtl",
reversed: this.reversed,
[CSS.reversed]: this.reversed,
}}
style={barStyles}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const CSS = {
track: "track",
bar: "bar",
text: "text",
reversed: "reversed",
};

0 comments on commit 37c26d5

Please sign in to comment.