Skip to content

Commit

Permalink
Update App.test
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanbajracharya committed Dec 28, 2024
1 parent 945ba9c commit 7610963
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
44 changes: 29 additions & 15 deletions tests/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<App />);
render(<App />);

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);
});
});
10 changes: 8 additions & 2 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vitest/config'
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
Expand All @@ -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',
],
},
},
});

0 comments on commit 7610963

Please sign in to comment.