-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from ES2-UFPI/testePesquisar
Configurei corretamente os testes da pesquisa e app.js
- Loading branch information
Showing
10 changed files
with
58 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
'@babel/preset-react' | ||
] | ||
}; | ||
presets: ['@babel/preset-env', '@babel/preset-react'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
module.exports = { | ||
transform: { | ||
"^.+\\.jsx?$": "babel-jest" | ||
}, | ||
moduleNameMapper: { | ||
"\\.(css|less|scss|sass)$": "identity-obj-proxy" | ||
}, | ||
moduleFileExtensions: ["js", "jsx"], | ||
testMatch: ["**/__tests__/**/*.js?(x)", "**/?(*.)+(spec|test).js?(x)"], | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"] | ||
}; | ||
|
||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'babel-jest', | ||
}, | ||
transformIgnorePatterns: [ | ||
'/node_modules/(?!(axios|react-dnd|dnd-core)|@react-dnd/)', | ||
], | ||
moduleNameMapper: { | ||
'\\.(css|less|sass|scss)$': 'identity-obj-proxy' | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/src/setupTests.js'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
|
||
test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
const linkElement = screen.getByText(/Pesquisar/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom'; | ||
// src/setupTests.js | ||
import '@testing-library/jest-dom'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react"; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Pesquisar from "../components/Pesquisar"; | ||
|
||
describe('Pesquisar Roteiro', () => { | ||
test('renders input element', () => { | ||
render(<Pesquisar />); | ||
const inputElement = screen.getByPlaceholderText(/pesquisar roteiros/i); | ||
expect(inputElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('updates input value on change', () => { | ||
render(<Pesquisar />); | ||
const inputElement = screen.getByPlaceholderText(/pesquisar roteiros/i); | ||
fireEvent.change(inputElement, { target: { value: 'Novo Título' } }); | ||
expect(inputElement.value).toBe('Novo Título'); | ||
}); | ||
|
||
test('shows alert when form is submitted with empty title', () => { | ||
render(<Pesquisar />); | ||
window.alert = jest.fn(); | ||
const formElement = screen.getByTestId('pesquisar-form'); | ||
fireEvent.submit(formElement); | ||
expect(window.alert).toHaveBeenCalledWith('É obrigatório o preenchimento do título'); | ||
}); | ||
}); |