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";
|
2024-12-30 21:06:59 +00:00
|
|
|
|
2026-03-17 19:30:21 +00:00
|
|
|
import { QueryablePlatform } from "interfaces/platform";
|
2022-12-07 17:59:38 +00:00
|
|
|
import PlatformCell from "./PlatformCell";
|
|
|
|
|
|
2026-03-17 19:30:21 +00:00
|
|
|
const QUERYABLE_PLATFORMS: QueryablePlatform[] = [
|
2024-12-30 21:06:59 +00:00
|
|
|
"windows",
|
|
|
|
|
"darwin",
|
|
|
|
|
"linux",
|
2026-03-17 19:30:21 +00:00
|
|
|
"chrome",
|
2024-12-30 21:06:59 +00:00
|
|
|
];
|
2022-12-07 17:59:38 +00:00
|
|
|
|
|
|
|
|
describe("Platform cell", () => {
|
|
|
|
|
it("renders platform icons in correct order", () => {
|
2026-03-17 19:30:21 +00:00
|
|
|
render(<PlatformCell platforms={QUERYABLE_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 windowsIcon = screen.queryByTestId("windows-icon");
|
2026-03-17 19:30:21 +00:00
|
|
|
const linuxIcon = screen.queryByTestId("linux-icon");
|
|
|
|
|
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);
|
2026-03-17 19:30:21 +00:00
|
|
|
expect(icons?.firstChild?.nextSibling?.nextSibling?.nextSibling).toBe(
|
|
|
|
|
chromeIcon
|
|
|
|
|
);
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
2026-03-17 19:30:21 +00:00
|
|
|
it("renders --- when no platforms passed in", () => {
|
2023-07-17 21:09:12 +00:00
|
|
|
render(<PlatformCell platforms={[]} />);
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2026-03-17 19:30:21 +00:00
|
|
|
expect(screen.getByText(/---/i)).toBeInTheDocument();
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
|
|
|
|
});
|