Files
DefectingCat.github.io/__tests__/components/NavBar.test.tsx
Defectink c651389aa3 Add jest
2022-03-22 15:10:46 +08:00

28 lines
794 B
TypeScript

import { render, screen } from '@testing-library/react';
import NavBar from 'components/NavBar';
import '@testing-library/jest-dom';
describe('NavBar', () => {
it('renders a title', async () => {
render(<NavBar />);
const heading = await screen.findByText(/RUA!/i);
expect(heading).toBeInTheDocument();
});
it('renders menu items', async () => {
render(<NavBar />);
const home = await screen.findByText(/Home/i);
const blog = await screen.findByText(/Blog/i);
expect(home).toBeInTheDocument();
expect(blog).toBeInTheDocument();
expect(home.hasAttribute('href')).toBeTruthy();
expect(home.getAttribute('href')).toEqual('/');
expect(blog.hasAttribute('href')).toBeTruthy();
expect(blog.getAttribute('href')).toEqual('/blog');
});
});