DeleteReplicaModal.spec.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 DeleteTransferModal from "./DeleteTransferModal";
  18. describe("DeleteTransferModal", () => {
  19. let defaultProps: DeleteTransferModal["props"];
  20. beforeEach(() => {
  21. defaultProps = {
  22. hasDisks: false,
  23. onDeleteTransfer: jest.fn(),
  24. onDeleteDisks: jest.fn(),
  25. onRequestClose: jest.fn(),
  26. };
  27. });
  28. it("renders without crashing", () => {
  29. const { getByText } = render(<DeleteTransferModal {...defaultProps} />);
  30. expect(getByText("Delete Transfer")).toBeTruthy();
  31. });
  32. it("renders with disks", () => {
  33. render(<DeleteTransferModal {...defaultProps} hasDisks />);
  34. expect(
  35. TestUtils.select("DeleteTransferModal__ExtraMessage")?.textContent
  36. ).toContain("has been executed at least once");
  37. });
  38. it("is multiple replica selection with disks", () => {
  39. render(
  40. <DeleteTransferModal
  41. {...defaultProps}
  42. hasDisks
  43. isMultiTransferSelection
  44. />
  45. );
  46. expect(
  47. TestUtils.select("DeleteTransferModal__ExtraMessage")?.textContent
  48. ).toContain("have been executed at least once");
  49. });
  50. it("renders loading", () => {
  51. render(<DeleteTransferModal {...defaultProps} loading />);
  52. expect(TestUtils.select("DeleteTransferModal__Loading")).toBeTruthy();
  53. });
  54. });