mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Add near 100% unit test coverage for webclient websocket layer
This commit is contained in:
parent
8cc65b8967
commit
35be723ebf
26 changed files with 3932 additions and 0 deletions
29
webclient/src/websocket/events/game/gameEvents.spec.ts
Normal file
29
webclient/src/websocket/events/game/gameEvents.spec.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
jest.mock('../../persistence', () => ({
|
||||
GamePersistence: {
|
||||
joinGame: jest.fn(),
|
||||
leaveGame: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
|
||||
describe('joinGame event', () => {
|
||||
const { joinGame } = jest.requireActual('./joinGame');
|
||||
|
||||
it('delegates to GamePersistence.joinGame', () => {
|
||||
const data = { gameId: 5, player: { playerId: 1 } } as any;
|
||||
joinGame(data);
|
||||
expect(GamePersistence.joinGame).toHaveBeenCalledWith(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('leaveGame event', () => {
|
||||
const { leaveGame } = jest.requireActual('./leaveGame');
|
||||
|
||||
it('delegates to GamePersistence.leaveGame', () => {
|
||||
leaveGame(42 as any);
|
||||
expect(GamePersistence.leaveGame).toHaveBeenCalledWith(42);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue