2024-01-23 14:16:10 +00:00
|
|
|
import React from "react";
|
2023-07-17 21:09:12 +00:00
|
|
|
import { render, screen } from "@testing-library/react";
|
2023-02-21 14:16:38 +00:00
|
|
|
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2024-07-09 13:18:00 +00:00
|
|
|
import { QueryablePlatform } from "interfaces/platform";
|
2022-12-07 17:59:38 +00:00
|
|
|
import PlatformCell from "./PlatformCell";
|
|
|
|
|
|
2024-07-09 13:18:00 +00:00
|
|
|
const PLATFORMS: QueryablePlatform[] = ["windows", "darwin", "linux", "chrome"];
|
2022-12-07 17:59:38 +00:00
|
|
|
|
|
|
|
|
describe("Platform cell", () => {
|
|
|
|
|
it("renders platform icons in correct order", () => {
|
2023-07-17 21:09:12 +00:00
|
|
|
render(<PlatformCell platforms={PLATFORMS} />);
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2023-08-28 17:09:21 +00:00
|
|
|
const icons = screen.queryByTestId("icons");
|
|
|
|
|
const appleIcon = screen.queryByTestId("darwin-icon");
|
2022-12-07 17:59:38 +00:00
|
|
|
const linuxIcon = screen.queryByTestId("linux-icon");
|
|
|
|
|
const windowsIcon = screen.queryByTestId("windows-icon");
|
2023-06-06 12:58:32 +00:00
|
|
|
const chromeIcon = screen.queryByTestId("chrome-icon");
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2023-08-28 17:09:21 +00:00
|
|
|
expect(icons?.firstChild).toBe(appleIcon);
|
|
|
|
|
expect(icons?.firstChild?.nextSibling).toBe(windowsIcon);
|
|
|
|
|
expect(icons?.firstChild?.nextSibling?.nextSibling).toBe(linuxIcon);
|
|
|
|
|
expect(icons?.firstChild?.nextSibling?.nextSibling?.nextSibling).toBe(
|
|
|
|
|
chromeIcon
|
|
|
|
|
);
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
|
|
|
|
it("renders empty state", () => {
|
2023-07-17 21:09:12 +00:00
|
|
|
render(<PlatformCell platforms={[]} />);
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2023-02-21 14:16:38 +00:00
|
|
|
const emptyText = screen.queryByText(DEFAULT_EMPTY_CELL_VALUE);
|
2022-12-07 17:59:38 +00:00
|
|
|
|
|
|
|
|
expect(emptyText).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|