Skip to content

Commit

Permalink
fix(tests): add caveats and tests for SSRBase
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Sep 19, 2023
1 parent 7f92da5 commit a72ef63
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it, expect } from "vitest";
import { render, getByTestId } from "@testing-library/react";

import * as Icons from "../src";
import { Icon, IconBase, IconWeight } from "../src/lib";
import { Icon, IconBase, SSRBase, IconWeight } from "../src/lib";

const aliases = new Set([
"FileDotted",
Expand All @@ -19,7 +19,8 @@ const aliases = new Set([
]);

const isIcon = (candidate: any): candidate is Icon =>
"displayName" in candidate && candidate.displayName !== "IconBase";
"displayName" in candidate &&
!["IconBase", "SSRBase"].includes(candidate.displayName);

const allIcons = Object.entries(Icons).filter(
([name, module]) => !aliases.has(name) && isIcon(module)
Expand Down Expand Up @@ -161,4 +162,39 @@ describe("Custom icons can be rendered", () => {
const result = render(<CustomIcon weight="duotone" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
});

const CustomSSRIcon: Icon = forwardRef((props, ref) => (
<SSRBase ref={ref} {...props} weights={weights} />
));

CustomSSRIcon.displayName = "CustomSSRIcon";

it("Custom SSR icon [thin] renders", () => {
const result = render(<CustomSSRIcon weight="thin" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
it("Custom SSR icon [light] renders", () => {
const result = render(<CustomSSRIcon weight="light" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
it("Custom SSR icon [regular] renders", () => {
const result = render(
<CustomSSRIcon weight="regular" data-testid="test" />
);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
it("Custom SSR icon [bold] renders", () => {
const result = render(<CustomSSRIcon weight="bold" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
it("Custom SSR icon [fill] renders", () => {
const result = render(<CustomSSRIcon weight="fill" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
it("Custom SSR icon [duotone] renders", () => {
const result = render(
<CustomSSRIcon weight="duotone" data-testid="test" />
);
expect(getByTestId(result.container, "test")).toBeTruthy();
});
});

0 comments on commit a72ef63

Please sign in to comment.