diff --git a/README.md b/README.md index 4967f97..a3182b5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # listly +[![Deploy to GitHub Pages](https://github.com/nishanbajracharya/listly/actions/workflows/deploy.yml/badge.svg)](https://github.com/nishanbajracharya/listly/actions/workflows/deploy.yml) + Ranked list maker diff --git a/tests/components/App.test.tsx b/tests/components/App.test.tsx index 9daae62..7c6171a 100644 --- a/tests/components/App.test.tsx +++ b/tests/components/App.test.tsx @@ -7,24 +7,38 @@ import { render, screen, fireEvent } from '../../test-utils'; import en from '../../src/constants/localization/en.json'; describe('App component', () => { + const navigation = [ + { + lang: 'shell.nav.home', + path: '/listly/', + }, + { + lang: 'shell.nav.compare', + path: '/listly/compare', + }, + { + lang: 'shell.nav.rank', + path: '/listly/rank', + }, + ]; + it('renders App component', () => { - const { container } = render(); + render(); + + expect(screen.getByText(l(en['base.app.title']))).toBeInTheDocument(); - expect(screen.getByText(l(en['base.app.title']))).to.exist; - expect(screen.getAllByText(l(en['shell.nav.home']))).to.exist; - expect(screen.getAllByText(l(en['shell.nav.compare']))).to.exist; - expect(screen.getAllByText(l(en['shell.nav.rank']))).to.exist; + navigation.forEach((nav) => { + screen + .getAllByText(l(en[nav.lang])) + .forEach((node) => expect(node).toBeInTheDocument()); - const compareButton = screen.getByLabelText(l(en['shell.nav.compare'])); - fireEvent.click(compareButton); - expect(location.pathname).to.eq('/listly/compare'); + const navButton = screen.getByLabelText(l(en[nav.lang])); + fireEvent.click(navButton); + expect(location.pathname).to.eq(nav.path); + }); - const rankButton = screen.getByLabelText(l(en['shell.nav.rank'])); - fireEvent.click(rankButton); - expect(location.pathname).to.eq('/listly/rank'); - - const homeButton = screen.getByLabelText(l(en['shell.nav.home'])); - fireEvent.click(homeButton); - expect(location.pathname).to.eq('/listly/'); + const colorSchemeButton = screen.getByLabelText('Color Scheme Button'); + expect(colorSchemeButton).toBeInTheDocument(); + fireEvent.click(colorSchemeButton); }); }); diff --git a/vitest.config.ts b/vitest.config.ts index e387e6f..5237ffc 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from 'vitest/config' +import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { @@ -7,7 +7,13 @@ export default defineConfig({ setupFiles: './vitest.setup.mjs', coverage: { provider: 'istanbul', - exclude: ['**/test-utils/**', '**/tests/**', '**.config.cjs', 'src/main.tsx'] + exclude: [ + '**/test-utils/**', + '**/tests/**', + '**.config.cjs', + 'src/main.tsx', + 'dist', + ], }, }, });