2022-12-07 17:59:38 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { getByTestId, render, screen, within } 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
|
|
|
|
|
|
|
|
import PlatformCell from "./PlatformCell";
|
|
|
|
|
|
2023-06-06 12:58:32 +00:00
|
|
|
const PLATFORMS = ["windows", "darwin", "linux", "chrome"];
|
2022-12-07 17:59:38 +00:00
|
|
|
|
|
|
|
|
describe("Platform cell", () => {
|
|
|
|
|
it("renders platform icons in correct order", () => {
|
|
|
|
|
render(<PlatformCell value={PLATFORMS} />);
|
|
|
|
|
|
|
|
|
|
const icons = screen.queryAllByTestId("icon");
|
|
|
|
|
const appleIcon = screen.queryByTestId("apple-icon");
|
|
|
|
|
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-06-06 12:58:32 +00:00
|
|
|
expect(icons).toHaveLength(4);
|
2022-12-07 17:59:38 +00:00
|
|
|
expect(icons[0].firstChild).toBe(appleIcon);
|
2023-06-06 12:58:32 +00:00
|
|
|
expect(icons[1].firstChild).toBe(windowsIcon);
|
|
|
|
|
expect(icons[2].firstChild).toBe(linuxIcon);
|
|
|
|
|
expect(icons[3].firstChild).toBe(chromeIcon);
|
2022-12-07 17:59:38 +00:00
|
|
|
});
|
|
|
|
|
it("renders empty state", () => {
|
|
|
|
|
render(<PlatformCell value={[]} />);
|
|
|
|
|
|
|
|
|
|
const icons = screen.queryAllByTestId("icon");
|
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(icons).toHaveLength(0);
|
|
|
|
|
expect(emptyText).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|