Skip to content

Commit

Permalink
feat: Adding test to coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiorodriguezgarcia committed Apr 8, 2024
1 parent c6e6a12 commit 270f566
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions webapp/src/tests/Game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,30 @@ describe("Game Component", () => {
expect(nextButton).not.toBeDisabled();
});
});
it("displays correct answer after selecting wrong answer", async () => {
const data = {
question: "What is the capital of Spain?",
options: ["Madrid", "Barcelona", "Seville", "Valencia"],
};
mockAxios.onGet().reply(HttpStatusCode.Ok, data);
const { container } = render(<ChakraProvider theme={theme}><MemoryRouter><Game/></MemoryRouter></ChakraProvider>);
waitFor(() => {
const optionButton = container.querySelector("button");
fireEvent.click(optionButton);
expect(optionButton).toHaveStyle("background-color: red");
});
});
it("displays correct answer after selecting correct answer", async () => {
const data = {
question: "What is the capital of Spain?",
options: ["Madrid", "Barcelona", "Seville", "Valencia"],
};
mockAxios.onGet().reply(HttpStatusCode.Ok, data);
const { container } = render(<ChakraProvider theme={theme}><MemoryRouter><Game/></MemoryRouter></ChakraProvider>);
waitFor(() => {
const optionButton = container.querySelector("button");
fireEvent.click(optionButton);
expect(optionButton).toHaveStyle("background-color: green");
});
});
});

0 comments on commit 270f566

Please sign in to comment.