Adding a simple placeholder test
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,5 +5,6 @@ logs
|
|||||||
**/*.backup.*
|
**/*.backup.*
|
||||||
**/*.back.*
|
**/*.back.*
|
||||||
|
|
||||||
|
coverage
|
||||||
node_modules
|
node_modules
|
||||||
bower_components
|
bower_components
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"devel": "nodemon server.ts",
|
"devel": "nodemon server.ts",
|
||||||
"test": "jest"
|
"test": "jest --coverage --watch"
|
||||||
},
|
},
|
||||||
"author": "Domenico Testa",
|
"author": "Domenico Testa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -5,9 +5,17 @@ describe("Room", function () {
|
|||||||
let room: GameRoom = null;
|
let room: GameRoom = null;
|
||||||
|
|
||||||
describe("onMessage / dispatchMessage", () => {
|
describe("onMessage / dispatchMessage", () => {
|
||||||
it("* should handle if message is not registered", () => {
|
it("should be able to create a GameRoom instance", () => {
|
||||||
room = new GameRoom();
|
room = new GameRoom();
|
||||||
expect(room).not.toBeNull();
|
expect(room).not.toBeNull();
|
||||||
});
|
expect(room).toHaveProperty('dispatcher');
|
||||||
|
expect(room).toHaveProperty('currentDealer');
|
||||||
|
expect(room).toHaveProperty('gameType');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("after creation getSeatedPlayers should return an empty array", () => {
|
||||||
|
room = new GameRoom();
|
||||||
|
expect(room.getSeatedPlayers()).toEqual([]);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ export class GameRoom extends Room<GameState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSeatedPlayers(): Player[] {
|
getSeatedPlayers(): Player[] {
|
||||||
|
if (this.state === undefined) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const players = Array.from<Player>(this.state.players.values());
|
const players = Array.from<Player>(this.state.players.values());
|
||||||
return players.filter((p) => { return (p.playing) });
|
return players.filter((p) => { return (p.playing) });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user