diff --git a/__tests__/components/StatNumberCard.test.js b/__tests__/components/StatNumberCard.test.js new file mode 100644 index 0000000..1f3d77d --- /dev/null +++ b/__tests__/components/StatNumberCard.test.js @@ -0,0 +1,16 @@ +import {render, screen} from "@testing-library/react"; +import StatNumberCard from "../../components/StatNumberCard"; + +describe("StatNumberCard", () => { + it("should render the default icon", () => { + render( + + ); + const headingArray = screen.getAllByRole("heading"); + + headingArray.map((heading) => { + expect(heading).toBeInTheDocument(); + }); + }); +}); diff --git a/__tests__/lib.test.js b/__tests__/lib.test.js new file mode 100644 index 0000000..ffeb86a --- /dev/null +++ b/__tests__/lib.test.js @@ -0,0 +1,35 @@ +import {classNames, clientJwtDecode, fetcher} from '../lib/utils'; + +describe('clientJwtDecode', () => { + it('should return an object', () => { + const result = clientJwtDecode('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c') + expect(result).toBeTruthy() + }); + it('should return an error', () => { + try { + expect(clientJwtDecode(null)) + .toThrowError( + "Token must be defined or not null. Do better next time, thanks."); + + expect(clientJwtDecode({})) + .toThrowError( + "Token must be defined or not null. Do better next time, thanks."); + + } catch (error) { + } + }); +}); + +describe('fetcher', () => { + it('should return an 200-range response', () => { + const res = fetcher('https://tincre.com'); + expect(res).toBeTruthy() + }); +}); + +describe('classNames', () => { + it('should return a string', () => { + const classname = classNames('text-white bg-black'); + expect(classname).toBe('text-white bg-black'); + }); +}); diff --git a/components/DefaultStatsIcon.jsx b/components/DefaultStatsIcon.jsx new file mode 100644 index 0000000..8ba4ca3 --- /dev/null +++ b/components/DefaultStatsIcon.jsx @@ -0,0 +1,18 @@ +export default function DefaultStatsIcon() { + return ( + + + + + ); +} diff --git a/components/StatNumberCard.jsx b/components/StatNumberCard.jsx index bb1762b..c9ab791 100644 --- a/components/StatNumberCard.jsx +++ b/components/StatNumberCard.jsx @@ -1,28 +1,11 @@ +import DefaultStatsIcon from "./DefaultStatsIcon"; + export default function StatNumberCard({ icon, numberStat, text }) { return (
- {!icon ? : icon} + {!icon ? : icon}

{numberStat}

{text}

); } - -function DefaultStats1Icon() { - return ( - - - - - ); -}