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
|
|
|
|
|
|
|
|
import { ScheduledQueryablePlatform } from "interfaces/platform";
|
2022-12-07 17:59:38 +00:00
|
|
|
import PlatformCell from "./PlatformCell";
|
|
|
|
|
|
2024-12-30 21:06:59 +00:00
|
|
|
const SCHEDULED_QUERYABLE_PLATFORMS: ScheduledQueryablePlatform[] = [
|
|
|
|
|
"windows",
|
|
|
|
|
"darwin",
|
|
|
|
|
"linux",
|
|
|
|
|
];
|
2022-12-07 17:59:38 +00:00
|
|
|
|
|
|
|
|
describe("Platform cell", () => {
|
|
|
|
|
it("renders platform icons in correct order", () => {
|
2024-12-30 21:06:59 +00:00
|
|
|
render(<PlatformCell platforms={SCHEDULED_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 linuxIcon = screen.queryByTestId("linux-icon");
|
|
|
|
|
const windowsIcon = screen.queryByTestId("windows-icon");
|
|
|
|
|
|
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);
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
2024-12-30 21:06:59 +00:00
|
|
|
it("renders all platforms targeted when no platforms passed in and scheduled", () => {
|
2023-07-17 21:09:12 +00:00
|
|
|
render(<PlatformCell platforms={[]} />);
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2024-12-30 21:06:59 +00:00
|
|
|
const icons = screen.queryByTestId("icons");
|
|
|
|
|
const appleIcon = screen.queryByTestId("darwin-icon");
|
|
|
|
|
const linuxIcon = screen.queryByTestId("linux-icon");
|
|
|
|
|
const windowsIcon = screen.queryByTestId("windows-icon");
|
2022-12-07 17:59:38 +00:00
|
|
|
|
2024-12-30 21:06:59 +00:00
|
|
|
expect(icons?.firstChild).toBe(appleIcon);
|
|
|
|
|
expect(icons?.firstChild?.nextSibling).toBe(windowsIcon);
|
|
|
|
|
expect(icons?.firstChild?.nextSibling?.nextSibling).toBe(linuxIcon);
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
|
|
|
|
});
|