Progress.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2021-2024 Avaiga Private Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  5. * the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. import React from "react";
  14. import { render } from "@testing-library/react";
  15. import "@testing-library/jest-dom";
  16. import Progress from "./Progress";
  17. describe("Progress component", () => {
  18. it("renders circular progress without value (indeterminate)", () => {
  19. const { getByRole } = render(<Progress />);
  20. const elt = getByRole("progressbar");
  21. expect(elt).toHaveClass("MuiCircularProgress-root");
  22. });
  23. it("uses the class", async () => {
  24. const { getByRole } = render(<Progress className="taipy-progress" />);
  25. const elt = getByRole("progressbar");
  26. expect(elt).toHaveClass("taipy-progress");
  27. });
  28. it("renders circular progress with value (determinate)", () => {
  29. const { getByRole, getByText } = render(<Progress showValue value={50} />);
  30. const elt = getByRole("progressbar");
  31. const valueText = getByText("50%");
  32. expect(elt).toHaveClass("MuiCircularProgress-root");
  33. expect(valueText).toBeInTheDocument();
  34. });
  35. it("renders linear progress without value (inderminate)", () => {
  36. const { getByRole } = render(<Progress linear />);
  37. const elt = getByRole("progressbar");
  38. expect(elt).toHaveClass("MuiLinearProgress-root");
  39. });
  40. it("renders linear progress with value (determinate)", () => {
  41. const { getByRole, getByText } = render(<Progress linear showValue value={50} />);
  42. const elt = getByRole("progressbar");
  43. const valueText = getByText("50%");
  44. expect(elt).toHaveClass("MuiLinearProgress-root");
  45. expect(valueText).toBeInTheDocument();
  46. });
  47. });