Skip to content

Commit

Permalink
Add test for finished exercises message
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjenningz committed Oct 3, 2022
1 parent 2a10a33 commit 3447dcb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions __tests__/pages/exercises/[lessonSlug].test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,40 @@ describe('Exercises page', () => {
expect(incorrectExercisePreviews).toHaveLength(1)
})

test('Renders a finished all exercises message when the user finished all the exercises', async () => {
const mocks = [
{
request: { query: GET_EXERCISES },
result: {
data: {
...getExercisesData,
// Make it so the user answered all of the exercises correctly
exerciseSubmissions: getExercisesData.exercises.map(exercise => ({
exerciseId: exercise.id,
userAnswer: exercise.answer
}))
}
}
}
]

const { findByLabelText, findAllByText, findByText } = render(
<MockedProvider mocks={mocks} addTypename={false}>
<Exercises />
</MockedProvider>
)

const exercisePreviews = await findAllByText('Problem')
expect(exercisePreviews).toHaveLength(3)

const checkbox = await findByLabelText('Show incomplete exercises only')
fireEvent.click(checkbox)

await findByText(
'🎉 Congratulations! You finished all the exercises for this lesson! 🥳'
)
})

test('Should not render lessons nav card tab if lesson docUrl is null', async () => {
const mocks = [
{
Expand Down

0 comments on commit 3447dcb

Please sign in to comment.