mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
migrate to Protobuf ES
This commit is contained in:
parent
68e22d22bf
commit
fd55f4fb7f
133 changed files with 1745 additions and 1621 deletions
|
|
@ -15,6 +15,7 @@ vi.mock('../../persistence', () => ({
|
|||
import { makeCallbackHelpers } from '../../__mocks__/callbackHelpers';
|
||||
import { BackendService } from '../../services/BackendService';
|
||||
import { RoomPersistence } from '../../persistence';
|
||||
import { Command_CreateGame_ext, Command_JoinGame_ext, Command_LeaveRoom_ext, Command_RoomSay_ext } from 'generated/proto/room_commands_pb';
|
||||
import { createGame } from './createGame';
|
||||
import { joinGame } from './joinGame';
|
||||
import { leaveRoom } from './leaveRoom';
|
||||
|
|
@ -22,7 +23,7 @@ import { roomSay } from './roomSay';
|
|||
|
||||
const { getLastSendOpts, invokeOnSuccess } = makeCallbackHelpers(
|
||||
BackendService.sendRoomCommand as vi.Mock,
|
||||
// sendRoomCommand(roomId, commandName, params, options) — options at index 3
|
||||
// sendRoomCommand(roomId, ext, value, options) — options at index 3
|
||||
3
|
||||
);
|
||||
|
||||
|
|
@ -35,7 +36,9 @@ describe('createGame', () => {
|
|||
|
||||
it('calls sendRoomCommand with Command_CreateGame', () => {
|
||||
createGame(5, { maxPlayers: 4 } as any);
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(5, 'Command_CreateGame', { maxPlayers: 4 }, expect.any(Object));
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(
|
||||
5, Command_CreateGame_ext, expect.objectContaining({ maxPlayers: 4 }), expect.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it('onSuccess calls RoomPersistence.gameCreated with roomId', () => {
|
||||
|
|
@ -52,7 +55,9 @@ describe('joinGame', () => {
|
|||
|
||||
it('calls sendRoomCommand with Command_JoinGame', () => {
|
||||
joinGame(7, { gameId: 42, password: '' } as any);
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(7, 'Command_JoinGame', { gameId: 42, password: '' }, expect.any(Object));
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(
|
||||
7, Command_JoinGame_ext, expect.objectContaining({ gameId: 42, password: '' }), expect.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it('onSuccess calls RoomPersistence.joinedGame with roomId and gameId', () => {
|
||||
|
|
@ -69,7 +74,7 @@ describe('leaveRoom', () => {
|
|||
|
||||
it('calls sendRoomCommand with Command_LeaveRoom', () => {
|
||||
leaveRoom(3);
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(3, 'Command_LeaveRoom', {}, expect.any(Object));
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(3, Command_LeaveRoom_ext, expect.any(Object), expect.any(Object));
|
||||
});
|
||||
|
||||
it('onSuccess calls RoomPersistence.leaveRoom with roomId', () => {
|
||||
|
|
@ -86,7 +91,11 @@ describe('roomSay', () => {
|
|||
|
||||
it('calls sendRoomCommand with trimmed message', () => {
|
||||
roomSay(2, ' hello ');
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(2, 'Command_RoomSay', { message: 'hello' }, expect.any(Object));
|
||||
expect(BackendService.sendRoomCommand).toHaveBeenCalledWith(
|
||||
2,
|
||||
Command_RoomSay_ext,
|
||||
expect.objectContaining({ message: 'hello' })
|
||||
);
|
||||
});
|
||||
|
||||
it('does not call sendRoomCommand when message is blank', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue