mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 22:53:55 -07:00
upgrade packages
This commit is contained in:
parent
c62c336a11
commit
ae1bc3da38
30 changed files with 1138 additions and 1783 deletions
|
|
@ -1,8 +1,11 @@
|
|||
vi.mock('../store', () => ({ store: { dispatch: vi.fn() } }));
|
||||
// Use `vi.hoisted` so the mocked `store.dispatch` reference stays stable across
|
||||
// re-runs of the factory under `isolate: false`. See rooms.dispatch.spec.ts for
|
||||
// the same pattern and rationale.
|
||||
const { mockDispatch } = vi.hoisted(() => ({ mockDispatch: vi.fn() }));
|
||||
vi.mock('../store', () => ({ store: { dispatch: mockDispatch } }));
|
||||
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { Data } from '@app/types';
|
||||
import { store } from '..';
|
||||
import { Actions } from './game.actions';
|
||||
import { Dispatch } from './game.dispatch';
|
||||
import {
|
||||
|
|
@ -12,31 +15,35 @@ import {
|
|||
makePlayerProperties,
|
||||
} from './__mocks__/fixtures';
|
||||
|
||||
beforeEach(() => {
|
||||
mockDispatch.mockClear();
|
||||
});
|
||||
|
||||
describe('Dispatch', () => {
|
||||
it('clearStore dispatches Actions.clearStore()', () => {
|
||||
Dispatch.clearStore();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
});
|
||||
|
||||
it('gameJoined dispatches Actions.gameJoined()', () => {
|
||||
const data = create(Data.Event_GameJoinedSchema, { hostId: 1, playerId: 2 });
|
||||
Dispatch.gameJoined(data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameJoined(data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameJoined(data));
|
||||
});
|
||||
|
||||
it('gameLeft dispatches Actions.gameLeft()', () => {
|
||||
Dispatch.gameLeft(2);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameLeft(2));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameLeft(2));
|
||||
});
|
||||
|
||||
it('gameClosed dispatches Actions.gameClosed()', () => {
|
||||
Dispatch.gameClosed(3);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameClosed(3));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameClosed(3));
|
||||
});
|
||||
|
||||
it('gameHostChanged dispatches Actions.gameHostChanged()', () => {
|
||||
Dispatch.gameHostChanged(1, 7);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameHostChanged(1, 7));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameHostChanged(1, 7));
|
||||
});
|
||||
|
||||
it('gameStateChanged dispatches Actions.gameStateChanged()', () => {
|
||||
|
|
@ -44,156 +51,156 @@ describe('Dispatch', () => {
|
|||
playerList: [], gameStarted: false, activePlayerId: 0, activePhase: 0, secondsElapsed: 0
|
||||
});
|
||||
Dispatch.gameStateChanged(1, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameStateChanged(1, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameStateChanged(1, data));
|
||||
});
|
||||
|
||||
it('playerJoined dispatches Actions.playerJoined()', () => {
|
||||
const props = makePlayerProperties();
|
||||
Dispatch.playerJoined(1, props);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.playerJoined(1, props));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.playerJoined(1, props));
|
||||
});
|
||||
|
||||
it('playerLeft dispatches Actions.playerLeft()', () => {
|
||||
Dispatch.playerLeft(1, 2, 3);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.playerLeft(1, 2, 3));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.playerLeft(1, 2, 3));
|
||||
});
|
||||
|
||||
it('playerPropertiesChanged dispatches Actions.playerPropertiesChanged()', () => {
|
||||
const props = makePlayerProperties();
|
||||
Dispatch.playerPropertiesChanged(1, 2, props);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.playerPropertiesChanged(1, 2, props));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.playerPropertiesChanged(1, 2, props));
|
||||
});
|
||||
|
||||
it('kicked dispatches Actions.kicked()', () => {
|
||||
Dispatch.kicked(1);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.kicked(1));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.kicked(1));
|
||||
});
|
||||
|
||||
it('cardMoved dispatches Actions.cardMoved()', () => {
|
||||
const data = create(Data.Event_MoveCardSchema, { cardId: 1 });
|
||||
Dispatch.cardMoved(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardMoved(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardMoved(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardFlipped dispatches Actions.cardFlipped()', () => {
|
||||
const data = create(Data.Event_FlipCardSchema, { cardId: 1 });
|
||||
Dispatch.cardFlipped(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardFlipped(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardFlipped(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardDestroyed dispatches Actions.cardDestroyed()', () => {
|
||||
const data = create(Data.Event_DestroyCardSchema, { cardId: 1 });
|
||||
Dispatch.cardDestroyed(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardDestroyed(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardDestroyed(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardAttached dispatches Actions.cardAttached()', () => {
|
||||
const data = create(Data.Event_AttachCardSchema, { cardId: 1 });
|
||||
Dispatch.cardAttached(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardAttached(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardAttached(1, 2, data));
|
||||
});
|
||||
|
||||
it('tokenCreated dispatches Actions.tokenCreated()', () => {
|
||||
const data = create(Data.Event_CreateTokenSchema, { cardId: 1 });
|
||||
Dispatch.tokenCreated(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.tokenCreated(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.tokenCreated(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardAttrChanged dispatches Actions.cardAttrChanged()', () => {
|
||||
const data = create(Data.Event_SetCardAttrSchema, { cardId: 1 });
|
||||
Dispatch.cardAttrChanged(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardAttrChanged(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardAttrChanged(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardCounterChanged dispatches Actions.cardCounterChanged()', () => {
|
||||
const data = create(Data.Event_SetCardCounterSchema, { cardId: 1 });
|
||||
Dispatch.cardCounterChanged(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardCounterChanged(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardCounterChanged(1, 2, data));
|
||||
});
|
||||
|
||||
it('arrowCreated dispatches Actions.arrowCreated()', () => {
|
||||
const data = create(Data.Event_CreateArrowSchema, { arrowInfo: makeArrow() });
|
||||
Dispatch.arrowCreated(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.arrowCreated(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.arrowCreated(1, 2, data));
|
||||
});
|
||||
|
||||
it('arrowDeleted dispatches Actions.arrowDeleted()', () => {
|
||||
const data = create(Data.Event_DeleteArrowSchema, { arrowId: 3 });
|
||||
Dispatch.arrowDeleted(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.arrowDeleted(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.arrowDeleted(1, 2, data));
|
||||
});
|
||||
|
||||
it('counterCreated dispatches Actions.counterCreated()', () => {
|
||||
const data = create(Data.Event_CreateCounterSchema, { counterInfo: makeCounter() });
|
||||
Dispatch.counterCreated(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.counterCreated(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.counterCreated(1, 2, data));
|
||||
});
|
||||
|
||||
it('counterSet dispatches Actions.counterSet()', () => {
|
||||
const data = create(Data.Event_SetCounterSchema, { counterId: 1, value: 10 });
|
||||
Dispatch.counterSet(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.counterSet(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.counterSet(1, 2, data));
|
||||
});
|
||||
|
||||
it('counterDeleted dispatches Actions.counterDeleted()', () => {
|
||||
const data = create(Data.Event_DelCounterSchema, { counterId: 1 });
|
||||
Dispatch.counterDeleted(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.counterDeleted(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.counterDeleted(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardsDrawn dispatches Actions.cardsDrawn()', () => {
|
||||
const data = create(Data.Event_DrawCardsSchema, { number: 2, cards: [makeCard()] });
|
||||
Dispatch.cardsDrawn(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardsDrawn(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardsDrawn(1, 2, data));
|
||||
});
|
||||
|
||||
it('cardsRevealed dispatches Actions.cardsRevealed()', () => {
|
||||
const data = create(Data.Event_RevealCardsSchema, { zoneName: 'hand', cards: [] });
|
||||
Dispatch.cardsRevealed(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.cardsRevealed(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.cardsRevealed(1, 2, data));
|
||||
});
|
||||
|
||||
it('zoneShuffled dispatches Actions.zoneShuffled()', () => {
|
||||
const data = create(Data.Event_ShuffleSchema, { zoneName: 'deck', start: 0, end: 39 });
|
||||
Dispatch.zoneShuffled(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.zoneShuffled(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.zoneShuffled(1, 2, data));
|
||||
});
|
||||
|
||||
it('dieRolled dispatches Actions.dieRolled()', () => {
|
||||
const data = create(Data.Event_RollDieSchema, { sides: 6, value: 4, values: [4] });
|
||||
Dispatch.dieRolled(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.dieRolled(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.dieRolled(1, 2, data));
|
||||
});
|
||||
|
||||
it('activePlayerSet dispatches Actions.activePlayerSet()', () => {
|
||||
Dispatch.activePlayerSet(1, 3);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.activePlayerSet(1, 3));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.activePlayerSet(1, 3));
|
||||
});
|
||||
|
||||
it('activePhaseSet dispatches Actions.activePhaseSet()', () => {
|
||||
Dispatch.activePhaseSet(1, 2);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.activePhaseSet(1, 2));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.activePhaseSet(1, 2));
|
||||
});
|
||||
|
||||
it('turnReversed dispatches Actions.turnReversed()', () => {
|
||||
Dispatch.turnReversed(1, true);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.turnReversed(1, true));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.turnReversed(1, true));
|
||||
});
|
||||
|
||||
it('zoneDumped dispatches Actions.zoneDumped()', () => {
|
||||
const data = create(Data.Event_DumpZoneSchema, { zoneOwnerId: 1, zoneName: 'hand', numberCards: 3, isReversed: false });
|
||||
Dispatch.zoneDumped(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.zoneDumped(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.zoneDumped(1, 2, data));
|
||||
});
|
||||
|
||||
it('zonePropertiesChanged dispatches Actions.zonePropertiesChanged()', () => {
|
||||
const data = create(Data.Event_ChangeZonePropertiesSchema, { zoneName: 'deck', alwaysRevealTopCard: true, alwaysLookAtTopCard: false });
|
||||
Dispatch.zonePropertiesChanged(1, 2, data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.zonePropertiesChanged(1, 2, data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.zonePropertiesChanged(1, 2, data));
|
||||
});
|
||||
|
||||
it('gameSay dispatches Actions.gameSay()', () => {
|
||||
Dispatch.gameSay(1, 2, 'gg wp');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameSay(1, 2, 'gg wp'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameSay(1, 2, 'gg wp'));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -898,17 +898,20 @@ describe('2J: Turn, phase, and chat', () => {
|
|||
|
||||
it('GAME_SAY → appends message with mocked Date.now() as timeReceived', () => {
|
||||
const state = makeState();
|
||||
vi.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
const result = gamesReducer(state, {
|
||||
type: Types.GAME_SAY,
|
||||
gameId: 1,
|
||||
playerId: 2,
|
||||
message: 'gg',
|
||||
});
|
||||
vi.restoreAllMocks();
|
||||
const dateNowSpy = vi.spyOn(Date, 'now').mockReturnValue(123456789);
|
||||
try {
|
||||
const result = gamesReducer(state, {
|
||||
type: Types.GAME_SAY,
|
||||
gameId: 1,
|
||||
playerId: 2,
|
||||
message: 'gg',
|
||||
});
|
||||
|
||||
expect(result.games[1].messages).toHaveLength(1);
|
||||
expect(result.games[1].messages[0]).toEqual({ playerId: 2, message: 'gg', timeReceived: 123456789 });
|
||||
expect(result.games[1].messages).toHaveLength(1);
|
||||
expect(result.games[1].messages[0]).toEqual({ playerId: 2, message: 'gg', timeReceived: 123456789 });
|
||||
} finally {
|
||||
dateNowSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -55,12 +55,15 @@ export function makeGame(
|
|||
};
|
||||
}
|
||||
|
||||
export function makeMessage(overrides: Partial<Enriched.Message> = {}): Enriched.Message {
|
||||
export function makeMessage(overrides: Partial<Omit<Enriched.Message, '$typeName' | '$unknown'>> = {}): Enriched.Message {
|
||||
const { timeReceived = 0, ...protoOverrides } = overrides;
|
||||
return {
|
||||
message: 'hello',
|
||||
messageType: 0,
|
||||
timeReceived: 0,
|
||||
...overrides,
|
||||
...create(Data.Event_RoomSaySchema, {
|
||||
message: 'hello',
|
||||
messageType: 0,
|
||||
...protoOverrides,
|
||||
}),
|
||||
timeReceived,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,84 +1,95 @@
|
|||
vi.mock('..', () => ({ store: { dispatch: vi.fn() } }));
|
||||
// Use `vi.hoisted` so the mocked `store.dispatch` reference stays stable across
|
||||
// re-runs of the factory under `isolate: false`. Other dispatch specs mock the
|
||||
// same `..` path with their own factories; under the shared module graph, the
|
||||
// cache entry for `..` can flip between competing `vi.fn()` instances. Asserting
|
||||
// against the hoisted `mockDispatch` directly (rather than reaching through
|
||||
// `store.dispatch`) decouples the assertions from whatever the module cache
|
||||
// currently resolves `store` to.
|
||||
const { mockDispatch } = vi.hoisted(() => ({ mockDispatch: vi.fn() }));
|
||||
vi.mock('..', () => ({ store: { dispatch: mockDispatch } }));
|
||||
|
||||
import { store } from '..';
|
||||
import { Actions } from './rooms.actions';
|
||||
import { Dispatch } from './rooms.dispatch';
|
||||
import { makeGame, makeMessage, makeRoom, makeUser } from './__mocks__/rooms-fixtures';
|
||||
import { App } from '@app/types';
|
||||
|
||||
beforeEach(() => {
|
||||
mockDispatch.mockClear();
|
||||
});
|
||||
|
||||
describe('Dispatch', () => {
|
||||
it('clearStore dispatches Actions.clearStore()', () => {
|
||||
Dispatch.clearStore();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
});
|
||||
|
||||
it('updateRooms dispatches Actions.updateRooms()', () => {
|
||||
const rooms = [makeRoom()];
|
||||
Dispatch.updateRooms(rooms);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateRooms(rooms));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateRooms(rooms));
|
||||
});
|
||||
|
||||
it('joinRoom dispatches Actions.joinRoom()', () => {
|
||||
const roomInfo = makeRoom({ roomId: 2 });
|
||||
Dispatch.joinRoom(roomInfo);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.joinRoom(roomInfo));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.joinRoom(roomInfo));
|
||||
});
|
||||
|
||||
it('leaveRoom dispatches Actions.leaveRoom()', () => {
|
||||
Dispatch.leaveRoom(3);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.leaveRoom(3));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.leaveRoom(3));
|
||||
});
|
||||
|
||||
it('addMessage with message.name falsy → dispatches only Actions.addMessage()', () => {
|
||||
const message = { ...makeMessage(), name: undefined };
|
||||
Dispatch.addMessage(1, message);
|
||||
expect(store.dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.addMessage(1, message));
|
||||
expect(mockDispatch).toHaveBeenCalledTimes(1);
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.addMessage(1, message));
|
||||
});
|
||||
|
||||
it('addMessage with message.name truthy → dispatches Actions.addMessage()', () => {
|
||||
const message = { ...makeMessage(), name: 'Alice' };
|
||||
Dispatch.addMessage(1, message);
|
||||
expect(store.dispatch).toHaveBeenCalledTimes(1);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.addMessage(1, message));
|
||||
expect(mockDispatch).toHaveBeenCalledTimes(1);
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.addMessage(1, message));
|
||||
});
|
||||
|
||||
it('updateGames dispatches Actions.updateGames()', () => {
|
||||
const games = [makeGame()];
|
||||
Dispatch.updateGames(1, games);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateGames(1, games));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateGames(1, games));
|
||||
});
|
||||
|
||||
it('userJoined dispatches Actions.userJoined()', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.userJoined(1, user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.userJoined(1, user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.userJoined(1, user));
|
||||
});
|
||||
|
||||
it('userLeft dispatches Actions.userLeft()', () => {
|
||||
Dispatch.userLeft(1, 'Alice');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.userLeft(1, 'Alice'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.userLeft(1, 'Alice'));
|
||||
});
|
||||
|
||||
it('sortGames dispatches Actions.sortGames()', () => {
|
||||
Dispatch.sortGames(1, App.GameSortField.START_TIME, App.SortDirection.ASC);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(
|
||||
expect(mockDispatch).toHaveBeenCalledWith(
|
||||
Actions.sortGames(1, App.GameSortField.START_TIME, App.SortDirection.ASC)
|
||||
);
|
||||
});
|
||||
|
||||
it('removeMessages dispatches Actions.removeMessages()', () => {
|
||||
Dispatch.removeMessages(1, 'Alice', 5);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.removeMessages(1, 'Alice', 5));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.removeMessages(1, 'Alice', 5));
|
||||
});
|
||||
|
||||
it('gameCreated dispatches Actions.gameCreated()', () => {
|
||||
Dispatch.gameCreated(2);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gameCreated(2));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gameCreated(2));
|
||||
});
|
||||
|
||||
it('joinedGame dispatches Actions.joinedGame()', () => {
|
||||
Dispatch.joinedGame(1, 5);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.joinedGame(1, 5));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.joinedGame(1, 5));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
vi.mock('..', () => ({ store: { dispatch: vi.fn() } }));
|
||||
// Use `vi.hoisted` so the mocked `store.dispatch` reference stays stable across
|
||||
// re-runs of the factory under `isolate: false`. See rooms.dispatch.spec.ts for
|
||||
// the same pattern and rationale.
|
||||
const { mockDispatch } = vi.hoisted(() => ({ mockDispatch: vi.fn() }));
|
||||
vi.mock('..', () => ({ store: { dispatch: mockDispatch } }));
|
||||
|
||||
import { store } from '..';
|
||||
import { Actions } from './server.actions';
|
||||
import { Dispatch } from './server.dispatch';
|
||||
import { App, Data } from '@app/types';
|
||||
|
|
@ -17,378 +20,382 @@ import {
|
|||
makeWarnListItem,
|
||||
} from './__mocks__/server-fixtures';
|
||||
|
||||
beforeEach(() => {
|
||||
mockDispatch.mockClear();
|
||||
});
|
||||
|
||||
describe('Dispatch', () => {
|
||||
it('initialized dispatches Actions.initialized()', () => {
|
||||
Dispatch.initialized();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.initialized());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.initialized());
|
||||
});
|
||||
|
||||
it('clearStore dispatches Actions.clearStore()', () => {
|
||||
Dispatch.clearStore();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.clearStore());
|
||||
});
|
||||
|
||||
it('connectionAttempted dispatches Actions.connectionAttempted()', () => {
|
||||
Dispatch.connectionAttempted();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.connectionAttempted());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.connectionAttempted());
|
||||
});
|
||||
|
||||
it('loginSuccessful dispatches Actions.loginSuccessful()', () => {
|
||||
const options = makeLoginSuccessContext();
|
||||
Dispatch.loginSuccessful(options);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.loginSuccessful(options));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.loginSuccessful(options));
|
||||
});
|
||||
|
||||
it('loginFailed dispatches Actions.loginFailed()', () => {
|
||||
Dispatch.loginFailed();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.loginFailed());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.loginFailed());
|
||||
});
|
||||
|
||||
it('connectionFailed dispatches Actions.connectionFailed()', () => {
|
||||
Dispatch.connectionFailed();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.connectionFailed());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.connectionFailed());
|
||||
});
|
||||
|
||||
it('testConnectionSuccessful dispatches Actions.testConnectionSuccessful()', () => {
|
||||
Dispatch.testConnectionSuccessful();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.testConnectionSuccessful());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.testConnectionSuccessful());
|
||||
});
|
||||
|
||||
it('testConnectionFailed dispatches Actions.testConnectionFailed()', () => {
|
||||
Dispatch.testConnectionFailed();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.testConnectionFailed());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.testConnectionFailed());
|
||||
});
|
||||
|
||||
it('updateBuddyList dispatches Actions.updateBuddyList()', () => {
|
||||
const list = [makeUser()];
|
||||
Dispatch.updateBuddyList(list);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateBuddyList(list));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateBuddyList(list));
|
||||
});
|
||||
|
||||
it('addToBuddyList dispatches Actions.addToBuddyList()', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.addToBuddyList(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.addToBuddyList(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.addToBuddyList(user));
|
||||
});
|
||||
|
||||
it('removeFromBuddyList dispatches Actions.removeFromBuddyList()', () => {
|
||||
Dispatch.removeFromBuddyList('Alice');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.removeFromBuddyList('Alice'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.removeFromBuddyList('Alice'));
|
||||
});
|
||||
|
||||
it('updateIgnoreList dispatches Actions.updateIgnoreList()', () => {
|
||||
const list = [makeUser()];
|
||||
Dispatch.updateIgnoreList(list);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateIgnoreList(list));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateIgnoreList(list));
|
||||
});
|
||||
|
||||
it('addToIgnoreList dispatches Actions.addToIgnoreList()', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.addToIgnoreList(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.addToIgnoreList(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.addToIgnoreList(user));
|
||||
});
|
||||
|
||||
it('removeFromIgnoreList dispatches Actions.removeFromIgnoreList()', () => {
|
||||
Dispatch.removeFromIgnoreList('Bob');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.removeFromIgnoreList('Bob'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.removeFromIgnoreList('Bob'));
|
||||
});
|
||||
|
||||
it('updateInfo dispatches Actions.updateInfo({ name, version })', () => {
|
||||
Dispatch.updateInfo('Servatrice', '2.9');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateInfo({ name: 'Servatrice', version: '2.9' }));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateInfo({ name: 'Servatrice', version: '2.9' }));
|
||||
});
|
||||
|
||||
it('updateStatus dispatches Actions.updateStatus({ state, description })', () => {
|
||||
Dispatch.updateStatus(App.StatusEnum.CONNECTED, 'ok');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateStatus({ state: App.StatusEnum.CONNECTED, description: 'ok' }));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateStatus({ state: App.StatusEnum.CONNECTED, description: 'ok' }));
|
||||
});
|
||||
|
||||
it('updateUser dispatches Actions.updateUser()', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.updateUser(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateUser(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateUser(user));
|
||||
});
|
||||
|
||||
it('updateUsers dispatches Actions.updateUsers()', () => {
|
||||
const users = [makeUser()];
|
||||
Dispatch.updateUsers(users);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateUsers(users));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateUsers(users));
|
||||
});
|
||||
|
||||
it('userJoined dispatches Actions.userJoined()', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.userJoined(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.userJoined(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.userJoined(user));
|
||||
});
|
||||
|
||||
it('userLeft dispatches Actions.userLeft()', () => {
|
||||
Dispatch.userLeft('Carol');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.userLeft('Carol'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.userLeft('Carol'));
|
||||
});
|
||||
|
||||
it('viewLogs dispatches Actions.viewLogs()', () => {
|
||||
const logs = [create(Data.ServerInfo_ChatMessageSchema, { targetType: 'room' })];
|
||||
Dispatch.viewLogs(logs);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.viewLogs(logs));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.viewLogs(logs));
|
||||
});
|
||||
|
||||
it('clearLogs dispatches Actions.clearLogs()', () => {
|
||||
Dispatch.clearLogs();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.clearLogs());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.clearLogs());
|
||||
});
|
||||
|
||||
it('serverMessage dispatches Actions.serverMessage()', () => {
|
||||
Dispatch.serverMessage('Welcome!');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.serverMessage('Welcome!'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.serverMessage('Welcome!'));
|
||||
});
|
||||
|
||||
it('registrationRequiresEmail dispatches correctly', () => {
|
||||
Dispatch.registrationRequiresEmail();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationRequiresEmail());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationRequiresEmail());
|
||||
});
|
||||
|
||||
it('registrationSuccess dispatches correctly', () => {
|
||||
Dispatch.registrationSuccess();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationSuccess());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationSuccess());
|
||||
});
|
||||
|
||||
it('registrationFailed passes reason and endTime to action', () => {
|
||||
Dispatch.registrationFailed('reason', 999);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationFailed('reason', 999));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationFailed('reason', 999));
|
||||
});
|
||||
|
||||
it('registrationFailed passes reason only when no endTime', () => {
|
||||
Dispatch.registrationFailed('plain reason');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationFailed('plain reason', undefined));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationFailed('plain reason', undefined));
|
||||
});
|
||||
|
||||
it('registrationEmailError dispatches correctly', () => {
|
||||
Dispatch.registrationEmailError('bad');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationEmailError('bad'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationEmailError('bad'));
|
||||
});
|
||||
|
||||
it('registrationPasswordError dispatches correctly', () => {
|
||||
Dispatch.registrationPasswordError('weak');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationPasswordError('weak'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationPasswordError('weak'));
|
||||
});
|
||||
|
||||
it('registrationUserNameError dispatches correctly', () => {
|
||||
Dispatch.registrationUserNameError('taken');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.registrationUserNameError('taken'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.registrationUserNameError('taken'));
|
||||
});
|
||||
|
||||
it('accountAwaitingActivation dispatches correctly', () => {
|
||||
const options = makePendingActivationContext();
|
||||
Dispatch.accountAwaitingActivation(options);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountAwaitingActivation(options));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountAwaitingActivation(options));
|
||||
});
|
||||
|
||||
it('accountActivationSuccess dispatches correctly', () => {
|
||||
Dispatch.accountActivationSuccess();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountActivationSuccess());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountActivationSuccess());
|
||||
});
|
||||
|
||||
it('accountActivationFailed dispatches correctly', () => {
|
||||
Dispatch.accountActivationFailed();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountActivationFailed());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountActivationFailed());
|
||||
});
|
||||
|
||||
it('resetPassword dispatches correctly', () => {
|
||||
Dispatch.resetPassword();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.resetPassword());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.resetPassword());
|
||||
});
|
||||
|
||||
it('resetPasswordFailed dispatches correctly', () => {
|
||||
Dispatch.resetPasswordFailed();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.resetPasswordFailed());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.resetPasswordFailed());
|
||||
});
|
||||
|
||||
it('resetPasswordChallenge dispatches correctly', () => {
|
||||
Dispatch.resetPasswordChallenge();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.resetPasswordChallenge());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.resetPasswordChallenge());
|
||||
});
|
||||
|
||||
it('resetPasswordSuccess dispatches correctly', () => {
|
||||
Dispatch.resetPasswordSuccess();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.resetPasswordSuccess());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.resetPasswordSuccess());
|
||||
});
|
||||
|
||||
it('adjustMod dispatches Actions.adjustMod()', () => {
|
||||
Dispatch.adjustMod('Dan', true, false);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.adjustMod('Dan', true, false));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.adjustMod('Dan', true, false));
|
||||
});
|
||||
|
||||
it('reloadConfig dispatches correctly', () => {
|
||||
Dispatch.reloadConfig();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.reloadConfig());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.reloadConfig());
|
||||
});
|
||||
|
||||
it('shutdownServer dispatches correctly', () => {
|
||||
Dispatch.shutdownServer();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.shutdownServer());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.shutdownServer());
|
||||
});
|
||||
|
||||
it('updateServerMessage dispatches correctly', () => {
|
||||
Dispatch.updateServerMessage();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateServerMessage());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateServerMessage());
|
||||
});
|
||||
|
||||
it('accountPasswordChange dispatches correctly', () => {
|
||||
Dispatch.accountPasswordChange();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountPasswordChange());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountPasswordChange());
|
||||
});
|
||||
|
||||
it('accountEditChanged dispatches correctly', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.accountEditChanged(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountEditChanged(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountEditChanged(user));
|
||||
});
|
||||
|
||||
it('accountImageChanged dispatches correctly', () => {
|
||||
const user = makeUser();
|
||||
Dispatch.accountImageChanged(user);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.accountImageChanged(user));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.accountImageChanged(user));
|
||||
});
|
||||
|
||||
it('getUserInfo dispatches correctly', () => {
|
||||
const userInfo = makeUser({ name: 'Frank' });
|
||||
Dispatch.getUserInfo(userInfo);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.getUserInfo(userInfo));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.getUserInfo(userInfo));
|
||||
});
|
||||
|
||||
it('notifyUser dispatches correctly', () => {
|
||||
const notification = create(Data.Event_NotifyUserSchema, { type: 1, warningReason: '', customTitle: '', customContent: '' });
|
||||
Dispatch.notifyUser(notification);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.notifyUser(notification));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.notifyUser(notification));
|
||||
});
|
||||
|
||||
it('serverShutdown dispatches correctly', () => {
|
||||
const data = create(Data.Event_ServerShutdownSchema, { reason: 'maintenance', minutes: 5 });
|
||||
Dispatch.serverShutdown(data);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.serverShutdown(data));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.serverShutdown(data));
|
||||
});
|
||||
|
||||
it('userMessage dispatches correctly', () => {
|
||||
const messageData = create(Data.Event_UserMessageSchema, { senderName: 'Alice', receiverName: 'Bob', message: 'hey' });
|
||||
Dispatch.userMessage(messageData);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.userMessage(messageData));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.userMessage(messageData));
|
||||
});
|
||||
|
||||
it('addToList dispatches correctly', () => {
|
||||
Dispatch.addToList('buddyList', 'Grace');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.addToList('buddyList', 'Grace'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.addToList('buddyList', 'Grace'));
|
||||
});
|
||||
|
||||
it('removeFromList dispatches correctly', () => {
|
||||
Dispatch.removeFromList('buddyList', 'Hank');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.removeFromList('buddyList', 'Hank'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.removeFromList('buddyList', 'Hank'));
|
||||
});
|
||||
|
||||
it('banFromServer dispatches correctly', () => {
|
||||
Dispatch.banFromServer('Ira');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.banFromServer('Ira'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.banFromServer('Ira'));
|
||||
});
|
||||
|
||||
it('banHistory dispatches correctly', () => {
|
||||
const history = [makeBanHistoryItem()];
|
||||
Dispatch.banHistory('Ira', history);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.banHistory('Ira', history));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.banHistory('Ira', history));
|
||||
});
|
||||
|
||||
it('warnHistory dispatches correctly', () => {
|
||||
const history = [makeWarnHistoryItem()];
|
||||
Dispatch.warnHistory('Jack', history);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.warnHistory('Jack', history));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.warnHistory('Jack', history));
|
||||
});
|
||||
|
||||
it('warnListOptions dispatches correctly', () => {
|
||||
const list = [makeWarnListItem()];
|
||||
Dispatch.warnListOptions(list);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.warnListOptions(list));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.warnListOptions(list));
|
||||
});
|
||||
|
||||
it('warnUser dispatches correctly', () => {
|
||||
Dispatch.warnUser('Kelly');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.warnUser('Kelly'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.warnUser('Kelly'));
|
||||
});
|
||||
|
||||
it('grantReplayAccess dispatches correctly', () => {
|
||||
Dispatch.grantReplayAccess(7, 'Moe');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.grantReplayAccess(7, 'Moe'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.grantReplayAccess(7, 'Moe'));
|
||||
});
|
||||
|
||||
it('forceActivateUser dispatches correctly', () => {
|
||||
Dispatch.forceActivateUser('Ned', 'Moe');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.forceActivateUser('Ned', 'Moe'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.forceActivateUser('Ned', 'Moe'));
|
||||
});
|
||||
|
||||
it('getAdminNotes dispatches correctly', () => {
|
||||
Dispatch.getAdminNotes('Ned', 'notes');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.getAdminNotes('Ned', 'notes'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.getAdminNotes('Ned', 'notes'));
|
||||
});
|
||||
|
||||
it('updateAdminNotes dispatches correctly', () => {
|
||||
Dispatch.updateAdminNotes('Ned', 'updated');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.updateAdminNotes('Ned', 'updated'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.updateAdminNotes('Ned', 'updated'));
|
||||
});
|
||||
|
||||
it('replayList dispatches correctly', () => {
|
||||
const list = [makeReplayMatch()];
|
||||
Dispatch.replayList(list);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.replayList(list));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.replayList(list));
|
||||
});
|
||||
|
||||
it('replayAdded dispatches correctly', () => {
|
||||
const match = makeReplayMatch();
|
||||
Dispatch.replayAdded(match);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.replayAdded(match));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.replayAdded(match));
|
||||
});
|
||||
|
||||
it('replayModifyMatch dispatches correctly', () => {
|
||||
Dispatch.replayModifyMatch(5, true);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.replayModifyMatch(5, true));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.replayModifyMatch(5, true));
|
||||
});
|
||||
|
||||
it('replayDeleteMatch dispatches correctly', () => {
|
||||
Dispatch.replayDeleteMatch(5);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.replayDeleteMatch(5));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.replayDeleteMatch(5));
|
||||
});
|
||||
|
||||
it('backendDecks dispatches correctly', () => {
|
||||
const deckList = makeDeckList();
|
||||
Dispatch.backendDecks(deckList);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.backendDecks(deckList));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.backendDecks(deckList));
|
||||
});
|
||||
|
||||
it('deckNewDir dispatches correctly', () => {
|
||||
Dispatch.deckNewDir('a/b', 'newFolder');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.deckNewDir('a/b', 'newFolder'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.deckNewDir('a/b', 'newFolder'));
|
||||
});
|
||||
|
||||
it('deckDelDir dispatches correctly', () => {
|
||||
Dispatch.deckDelDir('a/b');
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.deckDelDir('a/b'));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.deckDelDir('a/b'));
|
||||
});
|
||||
|
||||
it('deckUpload dispatches correctly', () => {
|
||||
const treeItem = makeDeckTreeItem();
|
||||
Dispatch.deckUpload('a/b', treeItem);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.deckUpload('a/b', treeItem));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.deckUpload('a/b', treeItem));
|
||||
});
|
||||
|
||||
it('deckDelete dispatches correctly', () => {
|
||||
Dispatch.deckDelete(42);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.deckDelete(42));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.deckDelete(42));
|
||||
});
|
||||
|
||||
it('gamesOfUser dispatches correctly', () => {
|
||||
const response = create(Data.Response_GetGamesOfUserSchema, { roomList: [], gameList: [] });
|
||||
Dispatch.gamesOfUser('alice', response);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.gamesOfUser('alice', response));
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.gamesOfUser('alice', response));
|
||||
});
|
||||
|
||||
it('clearRegistrationErrors dispatches correctly', () => {
|
||||
Dispatch.clearRegistrationErrors();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(Actions.clearRegistrationErrors());
|
||||
expect(mockDispatch).toHaveBeenCalledWith(Actions.clearRegistrationErrors());
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue