Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions __tests__/components/StatNumberCard.test.js
Original file line number Diff line number Diff line change
@@ -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(
<StatNumberCard {
...{ icon: undefined, numberStat: 300, text: 'huge' }} />
);
const headingArray = screen.getAllByRole("heading");

headingArray.map((heading) => {
expect(heading).toBeInTheDocument();
});
});
});
35 changes: 35 additions & 0 deletions __tests__/lib.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
18 changes: 18 additions & 0 deletions components/DefaultStatsIcon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function DefaultStatsIcon() {
return (
<svg
className="mx-auto mb-4 text-indigo-500"
width={48}
height={48}
viewBox="0 0 48 48"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M25.6 22.9C25.7 23 25.8 23 26 23H33C33.6 23 34 22.6 34 22C34 21.8 34 21.7 33.9 21.6L30.4 14.6C30.1 14.1 29.5 13.9 29 14.2C28.9 14.3 28.7 14.4 28.6 14.6L25.1 21.6C24.9 22 25.1 22.6 25.6 22.9ZM29.5 17.2L31.4 21H27.6L29.5 17.2ZM18.5 14C16 14 14 16 14 18.5C14 21 16 23 18.5 23C21 23 23 21 23 18.5C23 16 21 14 18.5 14ZM18.5 21C17.1 21 16 19.9 16 18.5C16 17.1 17.1 16 18.5 16C19.9 16 21 17.1 21 18.5C21 19.9 19.9 21 18.5 21ZM22.7 25.3C22.3 24.9 21.7 24.9 21.3 25.3L18.5 28.1L15.7 25.3C15.3 24.9 14.7 24.9 14.3 25.3C13.9 25.7 13.9 26.3 14.3 26.7L17.1 29.5L14.3 32.3C13.9 32.7 13.9 33.3 14.3 33.7C14.7 34.1 15.3 34.1 15.7 33.7L18.5 30.9L21.3 33.7C21.7 34.1 22.3 34.1 22.7 33.7C23.1 33.3 23.1 32.7 22.7 32.3L19.9 29.5L22.7 26.7C23.1 26.3 23.1 25.7 22.7 25.3ZM33 25H26C25.4 25 25 25.4 25 26V33C25 33.6 25.4 34 26 34H33C33.6 34 34 33.6 34 33V26C34 25.4 33.6 25 33 25ZM32 32H27V27H32V32Z"
fill="currentColor"
/>
<circle cx={24} cy={24} r="23.5" stroke="currentColor" />
</svg>
);
}
23 changes: 3 additions & 20 deletions components/StatNumberCard.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
import DefaultStatsIcon from "./DefaultStatsIcon";

export default function StatNumberCard({ icon, numberStat, text }) {
return (
<div className="w-full md:w-1/2 lg:w-1/4 px-4 mb-8 text-center">
{!icon ? <DefaultStats1Icon /> : icon}
{!icon ? <DefaultStatsIcon /> : icon}
<h3 className="mb-2 text-2xl font-bold font-heading">{numberStat}</h3>
<p className="text-lg text-gray-500">{text}</p>
</div>
);
}

function DefaultStats1Icon() {
return (
<svg
className="mx-auto mb-4 text-indigo-500"
width={48}
height={48}
viewBox="0 0 48 48"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M25.6 22.9C25.7 23 25.8 23 26 23H33C33.6 23 34 22.6 34 22C34 21.8 34 21.7 33.9 21.6L30.4 14.6C30.1 14.1 29.5 13.9 29 14.2C28.9 14.3 28.7 14.4 28.6 14.6L25.1 21.6C24.9 22 25.1 22.6 25.6 22.9ZM29.5 17.2L31.4 21H27.6L29.5 17.2ZM18.5 14C16 14 14 16 14 18.5C14 21 16 23 18.5 23C21 23 23 21 23 18.5C23 16 21 14 18.5 14ZM18.5 21C17.1 21 16 19.9 16 18.5C16 17.1 17.1 16 18.5 16C19.9 16 21 17.1 21 18.5C21 19.9 19.9 21 18.5 21ZM22.7 25.3C22.3 24.9 21.7 24.9 21.3 25.3L18.5 28.1L15.7 25.3C15.3 24.9 14.7 24.9 14.3 25.3C13.9 25.7 13.9 26.3 14.3 26.7L17.1 29.5L14.3 32.3C13.9 32.7 13.9 33.3 14.3 33.7C14.7 34.1 15.3 34.1 15.7 33.7L18.5 30.9L21.3 33.7C21.7 34.1 22.3 34.1 22.7 33.7C23.1 33.3 23.1 32.7 22.7 32.3L19.9 29.5L22.7 26.7C23.1 26.3 23.1 25.7 22.7 25.3ZM33 25H26C25.4 25 25 25.4 25 26V33C25 33.6 25.4 34 26 34H33C33.6 34 34 33.6 34 33V26C34 25.4 33.6 25 33 25ZM32 32H27V27H32V32Z"
fill="currentColor"
/>
<circle cx={24} cy={24} r="23.5" stroke="currentColor" />
</svg>
);
}