Adding a simple placeholder test

This commit is contained in:
2021-02-14 15:02:50 +01:00
parent 5688eabded
commit 75b7a15a53
4 changed files with 15 additions and 3 deletions

1
.gitignore vendored
View File

@@ -5,5 +5,6 @@ logs
**/*.backup.*
**/*.back.*
coverage
node_modules
bower_components

View File

@@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"devel": "nodemon server.ts",
"test": "jest"
"test": "jest --coverage --watch"
},
"author": "Domenico Testa",
"license": "MIT",
@@ -36,4 +36,4 @@
"jest": "^26.6.3",
"nodemon": "^2.0.6"
}
}
}

View File

@@ -5,9 +5,17 @@ describe("Room", function () {
let room: GameRoom = null;
describe("onMessage / dispatchMessage", () => {
it("* should handle if message is not registered", () => {
it("should be able to create a GameRoom instance", () => {
room = new GameRoom();
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([]);
})
});
});

View File

@@ -51,6 +51,9 @@ export class GameRoom extends Room<GameState> {
}
getSeatedPlayers(): Player[] {
if (this.state === undefined) {
return [];
}
const players = Array.from<Player>(this.state.players.values());
return players.filter((p) => { return (p.playing) });
}