Skip to content

Commit

Permalink
added tests for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
JHLincoln committed Oct 16, 2024
1 parent 57254b1 commit 84e3042
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 12 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/InGame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function InGame() {
<div className="guess">
<h1>Guess a number component placeholder</h1>
<form>
<label htmlFor="number_guess">Guess a number between 1 and 100!</label>
<label htmlFor="number_guess" data-testId="guess-label">Guess a number between 1 and 100!</label>
<input type="number" id="number_guess" name="number_guess"></input>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Lobby.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function Lobby() {

<div className="share_link">
<h1>Share link component placeholder</h1>
<p>
<p data-testid="add-players-prompt">
Add up to 6 players using this link
</p>
<a> Link</a>
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/pages/RoundEnd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ export function RoundEnd() {
<p>
Placeholder for the display number to guess component
</p>
<p>
The number was: 42
</p>
<p data-testId="number-reveal">
The number was:
</p><br></br>
<p>42</p>
</div>

<div className="winner">
<p>
Placeholder for the winner component
</p>
<p>
<p >
The winner is... Player3!
</p>
</div>
Expand Down
4 changes: 1 addition & 3 deletions frontend/tests/pages/HomePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { BrowserRouter } from "react-router-dom";
import { HomePage } from "../../src/pages/HomePage";
import { describe, expect, test } from "vitest";


describe("Homepage tests", () => {
test("name of the game", () => {
render(
Expand All @@ -18,5 +17,4 @@ describe("Homepage tests", () => {
const heading = screen.getByTestId("game-name");
expect(heading.textContent).toEqual("Guess the number!");
});
});

});
16 changes: 15 additions & 1 deletion frontend/tests/pages/InGame.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@
//required imports
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { InGame } from "../../src/pages/InGame";
import { InGame } from "../../src/pages/InGame";
import { describe, expect, test } from "vitest";

describe("InGame tests", () => {
test("name of the game", () => {
render(
<BrowserRouter>
<InGame />
</BrowserRouter>
);

const heading = screen.getByTestId("guess-label");
expect(heading.textContent).toEqual("Guess a number between 1 and 100!");
});
});
17 changes: 16 additions & 1 deletion frontend/tests/pages/Lobby.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@
//required imports
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { Lobby } from "../../src/pages/Lobby";
import { Lobby } from "../../src/pages/Lobby";
import { describe, expect, test } from "vitest";


describe("Lobby tests", () => {
test("name of the game", () => {
render(
<BrowserRouter>
<Lobby />
</BrowserRouter>
);

const heading = screen.getByTestId("add-players-prompt");
expect(heading.textContent).toEqual("Add up to 6 players using this link");
});
});
16 changes: 15 additions & 1 deletion frontend/tests/pages/RoundEnd.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@
//required imports
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { RoundEnd } from "../../src/pages/RoundEnd";
import { RoundEnd } from "../../src/pages/RoundEnd";
import { describe, expect, test } from "vitest";

describe("Round end tests", () => {
test("name of the game", () => {
render(
<BrowserRouter>
<RoundEnd />
</BrowserRouter>
);

const heading = screen.getByTestId("number-reveal");
expect(heading.textContent).toEqual("The number was:");
});
});

0 comments on commit 84e3042

Please sign in to comment.