-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correção dos testes #95
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f91284
Added correct jest jsdom environment
luistak 42e77f5
Fixed answer provider test
luistak 487c230
Fixed question test
luistak 8bf5ef6
Fixed App and ranking tests
luistak 22f98aa
Exported firebase from mockFirebase
luistak 178b69b
removed personal data
luistak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
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
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 |
---|---|---|
|
@@ -13,6 +13,11 @@ const CityProvider = ({ city = fakeCity, children }) => { | |
})), | ||
})), | ||
})), | ||
options: jest.fn({ | ||
projectId: jest.fn(12345), | ||
}), | ||
auth: jest.fn().mockReturnThis(), | ||
signInWithCustomToken: jest.fn().mockResolvedValue(), | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creio que estes e outros mocks podem ser melhorados no futuro criando "customRenders", para cada um desses providers como neste exemplo |
||
return ( | ||
|
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,26 +1,41 @@ | ||
import React from 'react'; | ||
import { render, screen, wait } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
import Question from './Question'; | ||
|
||
import { ROLE_VOTER } from 'constants/userRoles'; | ||
|
||
import CityProvider from 'components/CityProvider/CityProvider'; | ||
import AnswersProvider from 'components/AnswersProvider/AnswersProvider'; | ||
import questionsService from 'components/AnswersProvider/answersService'; | ||
|
||
const storedAnswers = { 0: { answer: 'DT' }, 1: { answer: 'CT' } }; | ||
beforeEach(() => { | ||
jest | ||
.spyOn(questionsService, 'getAnsweredQuestions') | ||
.mockImplementation(() => Promise.resolve(storedAnswers)); | ||
}); | ||
|
||
jest.mock('components/CityProvider/CityProvider'); | ||
|
||
describe('Question', () => { | ||
it('renders the provided question', async () => { | ||
const mockSave = jest.fn(); | ||
const mockedUser = { role: ROLE_VOTER }; | ||
|
||
render( | ||
<CityProvider> | ||
<Question id={1} onSave={mockSave} /> | ||
</CityProvider>, | ||
<BrowserRouter> | ||
<CityProvider> | ||
<Question user={mockedUser} id={1} /> | ||
</CityProvider> | ||
</BrowserRouter>, | ||
{ | ||
wrapper: AnswersProvider, | ||
}, | ||
); | ||
|
||
expect(screen.getByText('Any question title 1')).toBeVisible(); | ||
userEvent.click(screen.getByText('Discordo')); | ||
userEvent.click(screen.getByText('Salvar')); | ||
await wait(() => expect(mockSave).toBeCalled()); | ||
expect(await screen.findByText('Any question title 2')).toBeInTheDocument(); | ||
|
||
expect(screen.getByLabelText('Discordo')).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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Além dos wrappers, estavam faltando estes dois campos que eram obrigatórios também