1
This commit is contained in:
@@ -185,4 +185,62 @@ describe('escapeFlow', () => {
|
||||
expect(result.scrollWorld).toBe(false);
|
||||
expect(result.playerFacing).toBe('right');
|
||||
});
|
||||
|
||||
it('plays left exit and right-facing entry when escape targets a scene start', async () => {
|
||||
const state = {
|
||||
...createState(),
|
||||
currentScenePreset: {
|
||||
id: 'scene-bridge',
|
||||
name: 'Bridge',
|
||||
description: 'Bridge',
|
||||
imageSrc: '/bridge.png',
|
||||
worldType: WorldType.WUXIA,
|
||||
connectedSceneIds: [],
|
||||
connections: [],
|
||||
npcs: [],
|
||||
treasureHints: [],
|
||||
},
|
||||
};
|
||||
const targetScene = {
|
||||
...state.currentScenePreset!,
|
||||
id: 'scene-east',
|
||||
name: 'East Street',
|
||||
};
|
||||
const option = {
|
||||
...createEscapeOption(),
|
||||
runtimePayload: {
|
||||
escapeTargetSceneId: targetScene.id,
|
||||
escapeEntry: 'from_left',
|
||||
},
|
||||
};
|
||||
const finalState = buildEscapeAfterSequence(state, option, targetScene);
|
||||
const committedStates: GameState[] = [];
|
||||
|
||||
const result = await playEscapeSequenceWithStorySync({
|
||||
setGameState: (nextState: GameState) => {
|
||||
committedStates.push(nextState);
|
||||
},
|
||||
state,
|
||||
option,
|
||||
finalState,
|
||||
sleepMs: async () => {
|
||||
await Promise.resolve();
|
||||
},
|
||||
});
|
||||
|
||||
expect(committedStates[0]).toEqual(expect.objectContaining({
|
||||
playerFacing: 'left',
|
||||
animationState: AnimationState.RUN,
|
||||
scrollWorld: true,
|
||||
}));
|
||||
expect(committedStates.some((committedState) =>
|
||||
committedState.currentScenePreset?.id === 'scene-east' &&
|
||||
committedState.playerX < 0 &&
|
||||
committedState.playerFacing === 'right',
|
||||
)).toBe(true);
|
||||
expect(result.currentScenePreset?.id).toBe('scene-east');
|
||||
expect(result.playerX).toBe(0);
|
||||
expect(result.playerFacing).toBe('right');
|
||||
expect(result.scrollWorld).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user