Skip to content

Commit

Permalink
question.test new test
Browse files Browse the repository at this point in the history
  • Loading branch information
uo287841 committed Apr 8, 2024
1 parent 12b9aaa commit cc977a1
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion webapp/src/components/Question.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,29 @@ describe('Question page', () => {
imgs = screen.getAllByRole("button")
expect(imgs.length).toBe(4)
});
});


it('should render a flags question if category is foods', async () => {
useAuthUser.mockReturnValue({ username: 'testUser' });

mockAxios.onGet('http://localhost:8000/imgs/foods/question').reply(200,
{
question: "Which of the following images corresponds to Tortilla?",
images:["TortillaImage","PaellaImage","CachopoImage","ChocoImage"]
});

render(<Question type="imgs" category="foods"/>);

await waitFor(() => {
expect(screen.getByText(/Which of the following images corresponds to/i)).toBeInTheDocument();
expect(screen.getByText(/Score/i)).toBeInTheDocument();
});

let imgs = []
imgs = screen.getAllByRole("button")
expect(imgs.length).toBe(4)
});
});



0 comments on commit cc977a1

Please sign in to comment.