{"size": 1471, "ext": "js", "max_stars_repo_path": "src/__tests__/Header.test.js", "max_stars_repo_name": "mirouhml/math-magicians", "max_stars_repo_stars_event_min_datetime": "2022-03-23T12:59:11.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T12:59:11.000Z", "max_issues_repo_path": "src/__tests__/Header.test.js", "max_issues_repo_name": "mirouhml/math-magicians", "max_issues_repo_issues_event_min_datetime": "2022-03-14T07:49:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T11:34:14.000Z", "max_forks_repo_path": "src/__tests__/Header.test.js", "max_forks_repo_name": "mirouhml/math-magicians", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 34.2093023256, "max_line_length": 69, "alphanum_fraction": 0.6580557444}
import { screen, render, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import React from 'react';
import renderer from 'react-test-renderer';
import Header from '../components/Header';

describe('Header component tests:', () => {
  it('Header component renders correctly', () => {
    const tree = renderer
      .create(<Header />)
      .toJSON();
    expect(tree).toMatchSnapshot();
  });

  it('Checking if the HomePage is the landing page', () => {
    const { container } = render(<Header />);
    const home = container.querySelector('.home');
    expect(home).toBeInTheDocument();
  });

  it('Switching the page then returning to the HomePage', () => {
    const { container } = render(<Header />);
    fireEvent.click(screen.getByText('Calculator'));
    fireEvent.click(screen.getByText('Home'));
    const home = container.querySelector('.home');
    expect(home).toBeInTheDocument();
  });

  it('Clicking on Calculator and getting the CalculatorPage', () => {
    const { container } = render(<Header />);
    fireEvent.click(screen.getByText('Calculator'));
    const page = container.querySelector('.calculator-page');
    expect(page).toBeInTheDocument();
  });

  it('Clicking on Quotes and getting the QuotesPage', () => {
    const { container } = render(<Header />);
    fireEvent.click(screen.getByText('Quotes'));
    const page = container.querySelector('.quotes');
    expect(page).toBeInTheDocument();
  });
});
