@uva-glass/component-library
Version:
React components UvA
59 lines (58 loc) • 2.67 kB
JavaScript
import { jsx as t } from "react/jsx-runtime";
import "../../index-dmBn99rF.js";
import { r as l, s as e, w as a } from "../../react.esm-DI5ilWeT.js";
import { u as i } from "../../index-hwMTfLfH.js";
import { useState as s } from "react";
import { VarIndicator as n } from "./VarIndicator.js";
const o = {
DRAFT: "Concept",
REJECTED: "Concept",
SUBMITTED: "Verificatie",
ACTIVE: "Actief"
};
jest.mock("components/Icon", () => ({
Icon: ({ name: r }) => /* @__PURE__ */ t("svg", { "data-testid": r })
}));
const T = () => {
const [r, c] = s(1);
return (
// When clicked the onClick callback updates currentStep from 1 to 2.
/* @__PURE__ */ t(
n,
{
label: o,
variant: "SUBMITTED",
maxSteps: 3,
currentStep: r,
onClick: () => c(2)
}
)
);
};
describe("VarIndicator", () => {
const r = jest.fn();
beforeEach(() => {
r.mockClear();
}), it("should render Concept (DRAFT)", () => {
l(/* @__PURE__ */ t(n, { label: o, variant: "DRAFT" })), expect(e.getByText("Concept")).toBeInTheDocument();
}), it("should render Concept (REJECTED)", () => {
l(/* @__PURE__ */ t(n, { label: o, variant: "REJECTED" })), expect(e.getByText("Concept")).toBeInTheDocument();
}), it("should render Concept (ACTIVE)", () => {
l(/* @__PURE__ */ t(n, { label: o, variant: "ACTIVE" })), expect(e.getByText("Actief")).toBeInTheDocument();
}), it("should render dots (SUBMITTED)", () => {
l(/* @__PURE__ */ t(n, { label: o, variant: "SUBMITTED", maxSteps: 3, currentStep: 0 })), expect(e.getByText("Verificatie")).toBeInTheDocument(), expect(e.getAllByTestId("CircleSmall")).toHaveLength(3), expect(e.queryByTestId("CircleSmallFilled")).not.toBeInTheDocument();
}), it("should render filled dots when currentStep != 0 (SUBMITTED)", () => {
l(/* @__PURE__ */ t(n, { label: o, variant: "SUBMITTED", maxSteps: 3, currentStep: 1, onClick: r }));
const c = e.getByText("Verificatie");
expect(c).toBeInTheDocument(), expect(e.getAllByTestId("CircleSmallFilled")).toHaveLength(1), expect(e.getAllByTestId("CircleSmall")).toHaveLength(2);
}), it("should render filled dots currentStep is updated (SUBMITTED)", async () => {
l(/* @__PURE__ */ t(T, {})), expect(e.getAllByTestId("CircleSmallFilled")).toHaveLength(1), expect(e.getAllByTestId("CircleSmall")).toHaveLength(2);
const c = e.getByText("Verificatie");
await i.click(c), await a(() => {
expect(e.getAllByTestId("CircleSmallFilled")).toHaveLength(2);
}), await a(() => {
expect(e.getAllByTestId("CircleSmall")).toHaveLength(1);
});
});
});
//# sourceMappingURL=VarIndicator.test.js.map