diff --git a/api/numberGame/Player.js b/api/numberGame/Player.js new file mode 100644 index 0000000..d5bd2be --- /dev/null +++ b/api/numberGame/Player.js @@ -0,0 +1,21 @@ +class Player { + constructor(id, name) { + this.id = id; + this.name = name; + this.currentGuess = null, + this.totalScore = 0 + } + + guess(num) { + this.currentGuess = num + } + + getTotalScore() { + return this.totalScore + } + wonRound() { + this.totalScore++ + } +} + +module.exports = Player \ No newline at end of file diff --git a/api/tests/numberGame/Player.test.js b/api/tests/numberGame/Player.test.js new file mode 100644 index 0000000..d3ee203 --- /dev/null +++ b/api/tests/numberGame/Player.test.js @@ -0,0 +1,27 @@ +const Player = require("../../numberGame/Player") + +describe('player', () => { + test('initiates with id, name, currentGuess (null) and totalScore (0)', () => { + const player = new Player('17326746', 'Bob') + expect(player.id).toBe('17326746') + expect(player.name).toBe('Bob') + expect(player.currentGuess).toEqual(null) + expect(player.totalScore).toEqual(0) + }) + + test('guess() replaces the players guess', () => { + const player = new Player('17326746', 'Bob') + player.guess(5) + expect(player.currentGuess).toBe(5) + }) + + test('getTotalScore returns total score', () => { + const player = new Player('17326746', 'Bob') + expect(player.getTotalScore()).toBe(0) + }) + test('wonRound adds 1 to total score', () => { + const player = new Player('17326746', 'Bob') + player.wonRound() + expect(player.totalScore).toEqual(1) + }) +}) \ No newline at end of file diff --git a/frontend/tests/pages/HomePage.test.jsx b/frontend/tests/pages/HomePage.test.jsx deleted file mode 100644 index a69e421..0000000 --- a/frontend/tests/pages/HomePage.test.jsx +++ /dev/null @@ -1,9 +0,0 @@ -// Tests for the homepage where the host can create a game - -//required imports -import { render, screen } from "@testing-library/react"; -import { BrowserRouter } from "react-router-dom"; -import { HomePage } from "../../src/pages/HomePage"; - - - diff --git a/frontend/tests/pages/InGame.test.jsx b/frontend/tests/pages/InGame.test.jsx deleted file mode 100644 index 06d9541..0000000 --- a/frontend/tests/pages/InGame.test.jsx +++ /dev/null @@ -1,7 +0,0 @@ -// Tests for the in game page where players can guess a number, and submit -// Everyone can all see the players in the game - -//required imports -import { render, screen } from "@testing-library/react"; -import { BrowserRouter } from "react-router-dom"; -import { InGame } from "../../src/pages/InGame"; \ No newline at end of file diff --git a/frontend/tests/pages/Lobby.test.jsx b/frontend/tests/pages/Lobby.test.jsx deleted file mode 100644 index 0a6f29e..0000000 --- a/frontend/tests/pages/Lobby.test.jsx +++ /dev/null @@ -1,7 +0,0 @@ -// Tests for the lobby page where the host and players can share a link to join -// the game, the host can start the game, and everyone can see who has joined - -//required imports -import { render, screen } from "@testing-library/react"; -import { BrowserRouter } from "react-router-dom"; -import { Lobby } from "../../src/pages/Lobby"; \ No newline at end of file diff --git a/frontend/tests/pages/RoundEnd.test.jsx b/frontend/tests/pages/RoundEnd.test.jsx deleted file mode 100644 index ade992d..0000000 --- a/frontend/tests/pages/RoundEnd.test.jsx +++ /dev/null @@ -1,7 +0,0 @@ -// Tests for the round end page where players can view the scoreboard, the number, the winner(s), -// and choose whether to go to the next round or quit the game - -//required imports -import { render, screen } from "@testing-library/react"; -import { BrowserRouter } from "react-router-dom"; -import { RoundEnd } from "../../src/pages/RoundEnd"; \ No newline at end of file