DeleteReplicaModal.spec.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright (C) 2023 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React from "react";
  15. import { render } from "@testing-library/react";
  16. import TestUtils from "@tests/TestUtils";
  17. import DeleteReplicaModal from "./";
  18. describe("DeleteReplicaModal", () => {
  19. let defaultProps: DeleteReplicaModal["props"];
  20. beforeEach(() => {
  21. defaultProps = {
  22. hasDisks: false,
  23. onDeleteReplica: jest.fn(),
  24. onDeleteDisks: jest.fn(),
  25. onRequestClose: jest.fn(),
  26. };
  27. });
  28. it("renders without crashing", () => {
  29. const { getByText } = render(<DeleteReplicaModal {...defaultProps} />);
  30. expect(getByText("Delete Replica")).toBeTruthy();
  31. });
  32. it("renders with disks", () => {
  33. render(<DeleteReplicaModal {...defaultProps} hasDisks />);
  34. expect(
  35. TestUtils.select("DeleteReplicaModal__ExtraMessage")?.textContent
  36. ).toContain("has been executed at least once");
  37. });
  38. it("is multiple replica selection with disks", () => {
  39. render(
  40. <DeleteReplicaModal {...defaultProps} hasDisks isMultiReplicaSelection />
  41. );
  42. expect(
  43. TestUtils.select("DeleteReplicaModal__ExtraMessage")?.textContent
  44. ).toContain("have been executed at least once");
  45. });
  46. it("renders loading", () => {
  47. render(<DeleteReplicaModal {...defaultProps} loading />);
  48. expect(TestUtils.select("DeleteReplicaModal__Loading")).toBeTruthy();
  49. });
  50. });