diff --git a/src/components/Nav/__tests__/Nav.test.tsx b/src/components/Nav/__tests__/Nav.test.tsx index ce49a07..d95f80f 100644 --- a/src/components/Nav/__tests__/Nav.test.tsx +++ b/src/components/Nav/__tests__/Nav.test.tsx @@ -16,31 +16,31 @@ describe('Nav component', () => { routes = { primary: [{ - slug: chance.string(), + slug: faker.lorem.slug(), icon: , - label: chance.string(), + label: faker.lorem.words(), page: , },{ - slug: chance.string(), + slug: faker.lorem.slug(), icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }], secondary: [{ - slug: chance.string(), + slug: faker.lorem.slug(), icon: , - label: chance.string(), + label: faker.lorem.words(), page: , },{ - slug: chance.string(), + slug: faker.lorem.slug(), icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }], tertiary: [{ - slug: chance.string(), + slug: faker.lorem.slug(), icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }] }; @@ -103,21 +103,21 @@ describe('Nav component', () => { it('should render a Nav with sub-headers', () => { routes.primary.push({ - slug: 'header-' + chance.string(), + slug: `header-${faker.lorem.slug()}`, icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }); routes.secondary?.push({ - slug: 'header-' + chance.string(), + slug: `header-${faker.lorem.slug()}`, icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }); routes.tertiary?.push({ - slug: 'header-' + chance.string(), + slug: `header-${faker.lorem.slug()}`, icon: , - label: chance.string(), + label: faker.lorem.words(), page: , }); diff --git a/src/providers/Profile/__tests__/Profile.test.tsx b/src/providers/Profile/__tests__/Profile.test.tsx index ac265a1..0802152 100644 --- a/src/providers/Profile/__tests__/Profile.test.tsx +++ b/src/providers/Profile/__tests__/Profile.test.tsx @@ -19,12 +19,12 @@ describe('Profile context provider', () => { beforeAll(() => { profile = { - id: chance.guid(), - firstName: chance.first(), - lastName: chance.last(), - bio: chance.paragraph(), - avatarUrl: 'https://via.placeholder.com/46', - website: chance.url(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), + bio: faker.person.bio(), + avatarUrl: faker.image.url({width: 48, height: 48}), + website: faker.internet.url(), loading: false, }; diff --git a/src/stories/Auth.stories.tsx b/src/stories/Auth.stories.tsx index 602fe3f..8f227ce 100644 --- a/src/stories/Auth.stories.tsx +++ b/src/stories/Auth.stories.tsx @@ -1,7 +1,7 @@ import React, {useState} from "react"; import {useParameter} from "@storybook/addons"; import type {Meta, StoryObj} from '@storybook/react'; -import {Chance} from 'chance'; +import {faker} from '@faker-js/faker'; import AccountBalanceIcon from '@mui/icons-material/AccountBalance'; import AllInclusiveIcon from '@mui/icons-material/AllInclusive'; import BlindIcon from '@mui/icons-material/Blind'; @@ -10,8 +10,6 @@ import {Auth} from '../components'; import type {Credentials, SignUpInfo, RecoverPasswordInfo} from '../components'; import {Profile, ProfileProvider} from "../providers"; -const chance = new Chance(new Chance().natural()); - // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction const meta: Meta = { title: 'Mui-Mas/Auth', @@ -25,12 +23,12 @@ const meta: Meta = { // eslint-disable-next-line @typescript-eslint/no-unused-vars (Story, context) => { const initialState: Profile | undefined = useParameter('profile', { - id: chance.guid(), - firstName: chance.first(), - lastName: chance.last(), - bio: chance.paragraph(), - avatarUrl: chance.url(), - website: chance.url(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), + bio: faker.person.bio(), + avatarUrl: faker.image.url(), + website: faker.internet.url(), loading: false, }); @@ -58,8 +56,8 @@ export const SignIn: Story = { args: { type: 'password', icon: , - title: chance.string(), - subTitle: `${chance.capitalize(chance.word())} ${chance.capitalize(chance.word())}`, + title: faker.lorem.words(), + subTitle: faker.lorem.words(), signInUrl: '/signin', signIn, signUpUrl: '/signup', @@ -73,8 +71,8 @@ export const SignUp: Story = { args: { type: 'signup', icon: , - title: chance.string(), - subTitle: `${chance.capitalize(chance.word())} ${chance.capitalize(chance.word())}`, + title: faker.lorem.words(), + subTitle: faker.lorem.words(), signInUrl: '/signin', signIn, signUpUrl: '/signup', @@ -88,8 +86,8 @@ export const RecoverPassword: Story = { args: { type: 'recover', icon: , - title: chance.string(), - subTitle: `${chance.capitalize(chance.word())} ${chance.capitalize(chance.word())}`, + title: faker.lorem.words(), + subTitle: faker.lorem.words(), signInUrl: '/signin', signIn, signUpUrl: '/signup', diff --git a/src/stories/AuthShell.stories.tsx b/src/stories/AuthShell.stories.tsx index d64d45f..21fde8d 100644 --- a/src/stories/AuthShell.stories.tsx +++ b/src/stories/AuthShell.stories.tsx @@ -1,14 +1,12 @@ import React, {useState} from "react"; import {useParameter} from "@storybook/addons"; import type {Meta, StoryObj} from '@storybook/react'; -import {Chance} from 'chance'; +import {faker} from '@faker-js/faker'; import {AuthShell} from '../components'; import type {Credentials, SignUpInfo, RecoverPasswordInfo} from '../components'; import {Profile, ProfileProvider} from "../providers"; -const chance = new Chance(new Chance().natural()); - // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction const meta: Meta = { title: 'Mui-Mas/AuthShell', @@ -22,12 +20,12 @@ const meta: Meta = { // eslint-disable-next-line @typescript-eslint/no-unused-vars (Story, context) => { const initialState: Profile | undefined = useParameter('profile', { - id: chance.guid(), - firstName: chance.first(), - lastName: chance.last(), - bio: chance.paragraph(), - avatarUrl: chance.url(), - website: chance.url(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), + bio: faker.person.bio(), + avatarUrl: faker.image.url(), + website: faker.internet.url(), loading: false, }); @@ -48,17 +46,17 @@ type Story = StoryObj; const config = { app: { - title: `${chance.capitalize(chance.word())} ${chance.capitalize(chance.word())}`, - description: chance.paragraph(), - icon: 'https://placehold.co/64', + title: faker.lorem.words(), + description: faker.lorem.paragraph(), + icon: faker.image.url({width: 48, height: 48}), logo: { - main: 'https://placehold.co/46', - contrast: 'https://placehold.co/46', + main: faker.image.url({width: 48, height: 48}), + contrast: faker.image.url({width: 48, height: 48}), }, copyright: { - holder: chance.name(), - year: Number(chance.year({min: 1995, max: new Date().getFullYear()})), - url: chance.url(), + holder: faker.person.fullName(), + year: faker.date.past({years: 3}).getFullYear(), + url: faker.internet.url(), }, pages: { home: '/', diff --git a/src/test-utils/test-setup.d.ts b/test-setup.d.ts similarity index 100% rename from src/test-utils/test-setup.d.ts rename to test-setup.d.ts diff --git a/tsconfig.json b/tsconfig.json index 62f6fd7..3979f3d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -100,6 +100,17 @@ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/test-utils/test-setup.d.ts"], - "exclude": ["node_modules", "build", "scripts", "jest", "examples"] + "include": [ + "test-setup.d.ts", + "src/**/*.ts", + "src/**/*.tsx" + ], + "exclude": [ + "node_modules", + "build", + "scripts", + "jest", + "coverage", + "example" + ] }