Skip to content

Commit

Permalink
racehorse:(#180) testes config
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriAlves5 committed Nov 1, 2023
1 parent 51dc11b commit 12438c4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

32 changes: 18 additions & 14 deletions src/tests/pages/AboutUs.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import AboutUs from '../../pages/AboutUs'
import { MemoryRouter } from 'react-router-dom'; // Importe o MemoryRouter
import AboutUs from '../../pages/AboutUs';

describe('Testando a página AboutUs', () => {
test('verifica se o título "Quem Somos" está sendo renderizado', () => {
render(<AboutUs />);
const title = screen.getByText(/Quem Somos/i);
expect(title).toBeInTheDocument();
});

test('verifica se o logo da Polícia Civil está sendo renderizado', () => {
render(<AboutUs />);
render(
<MemoryRouter>
<AboutUs />
</MemoryRouter>
);
const logo = screen.getByAltText(/PoliciaCivilLogo/i);
expect(logo).toBeInTheDocument();
});

test('verifica se o primeiro parágrafo está sendo renderizado', () => {
render(<AboutUs />);
render(
<MemoryRouter>
<AboutUs />
</MemoryRouter>
);
const paragraph1 = screen.getByText(/O PrintGO tem a finalidade de corrigir o problema chave que foi definido junto com a visão do produto,/i);
expect(paragraph1).toBeInTheDocument();
});

test('verifica se o segundo parágrafo está sendo renderizado', () => {
render(<AboutUs />);
render(
<MemoryRouter>
<AboutUs />
</MemoryRouter>
);
const paragraph2 = screen.getByText(/A aplicação web foi feita sob encomenda para a Polícia Civil do estado do Goiás pela Universidade de Brasília,/i);
expect(paragraph2).toBeInTheDocument();
});

test('verifica se a elipse está sendo renderizada', () => {
render(<AboutUs />);
const ellipse = screen.getByAltText('');
expect(ellipse).toBeInTheDocument();
});

});
19 changes: 16 additions & 3 deletions src/tests/pages/Contact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@ import { render, fireEvent, waitFor } from '@testing-library/react';
import Contact from '../../pages/Contact';
import emailjs from '@emailjs/browser';
import React from 'react';
import { BrowserRouter } from 'react-router-dom'; // Importe o BrowserRouter

jest.mock('@emailjs/browser');

describe('Contact Component', () => {
it('should render without crashing', () => {
render(<Contact />);
render(
<BrowserRouter>
<Contact />
</BrowserRouter>
);
});

it('should handle input change', () => {
const { getByPlaceholderText } = render(<Contact />);
const { getByPlaceholderText } = render(
<BrowserRouter>
<Contact />
</BrowserRouter>
);
const input = getByPlaceholderText('Digite seu nome');
fireEvent.change(input, { target: { value: 'Teste' } });
expect(input.value).toBe('Teste');
});

it('should handle form submission', async () => {
emailjs.send.mockResolvedValue({ status: 200, text: 'SUCCESS!' });
const { getByPlaceholderText, getByText } = render(<Contact />);
const { getByPlaceholderText, getByText } = render(
<BrowserRouter>
<Contact />
</BrowserRouter>
);
const nomeInput = getByPlaceholderText('Digite seu nome');
const emailInput = getByPlaceholderText('Digite seu email');
const assuntoInput = getByPlaceholderText('Assunto');
Expand Down

0 comments on commit 12438c4

Please sign in to comment.