MigrationDetailsContent.spec.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 MigrationDetailsContent from ".";
  17. import { MIGRATION_ITEM_DETAILS_MOCK } from "@tests/mocks/TransferMock";
  18. import { MINION_POOL_MOCK } from "@tests/mocks/MinionPoolMock";
  19. import { STORAGE_BACKEND_MOCK } from "@tests/mocks/StoragesMock";
  20. import { INSTANCE_MOCK } from "@tests/mocks/InstancesMock";
  21. import { NETWORK_MOCK } from "@tests/mocks/NetworksMock";
  22. import {
  23. OPENSTACK_ENDPOINT_MOCK,
  24. VMWARE_ENDPOINT_MOCK,
  25. } from "@tests/mocks/EndpointsMock";
  26. jest.mock("@src/components/modules/EndpointModule/EndpointLogos", () => ({
  27. __esModule: true,
  28. default: (props: any) => <div>{props.endpoint}</div>,
  29. }));
  30. jest.mock("react-router-dom", () => ({ Link: "a" }));
  31. describe("MigrationDetailsContent", () => {
  32. let defaultProps: MigrationDetailsContent["props"];
  33. beforeEach(() => {
  34. defaultProps = {
  35. item: MIGRATION_ITEM_DETAILS_MOCK,
  36. itemId: MIGRATION_ITEM_DETAILS_MOCK.id,
  37. minionPools: [MINION_POOL_MOCK],
  38. detailsLoading: false,
  39. storageBackends: [STORAGE_BACKEND_MOCK],
  40. instancesDetails: [INSTANCE_MOCK],
  41. instancesDetailsLoading: false,
  42. networks: [NETWORK_MOCK],
  43. sourceSchema: [],
  44. sourceSchemaLoading: false,
  45. destinationSchema: [],
  46. destinationSchemaLoading: false,
  47. endpoints: [OPENSTACK_ENDPOINT_MOCK, VMWARE_ENDPOINT_MOCK],
  48. page: "",
  49. onDeleteMigrationClick: jest.fn(),
  50. };
  51. });
  52. it("renders without crashing", () => {
  53. const { getByText } = render(<MigrationDetailsContent {...defaultProps} />);
  54. expect(getByText(MIGRATION_ITEM_DETAILS_MOCK.id)).toBeTruthy();
  55. });
  56. it("renders tasks page", () => {
  57. const { getByText } = render(
  58. <MigrationDetailsContent {...defaultProps} page="tasks" />
  59. );
  60. expect(
  61. getByText(
  62. MIGRATION_ITEM_DETAILS_MOCK.tasks[0].task_type.replace("_", " ")
  63. )
  64. ).toBeTruthy();
  65. });
  66. });