feat(engine): execute story actions via storyChoiceId
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { content } from '../../content/index';
|
||||
import { createGameState, executeStoryAction } from '../game';
|
||||
import { enterStoryNode } from '../story';
|
||||
|
||||
describe('executeStoryAction()', () => {
|
||||
it('applies the linked story choice', () => {
|
||||
const state = createGameState(content);
|
||||
enterStoryNode(state, content, 'fork_choice');
|
||||
executeStoryAction(state, content, 'pick_high_road');
|
||||
expect(state.storyFlags.route_a).toBe(true);
|
||||
expect(state.currentStoryNodeId).toBe('route_a_beat');
|
||||
});
|
||||
|
||||
it('throws when the choice is not available', () => {
|
||||
const state = createGameState(content);
|
||||
enterStoryNode(state, content, 'fork_choice');
|
||||
executeStoryAction(state, content, 'pick_high_road');
|
||||
// after taking route A, the current node has no choices, so follow_river (pick_b) is unavailable
|
||||
expect(() => executeStoryAction(state, content, 'follow_river')).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user