import { describe, expect, it } from 'vitest';
import { DialogueRunner, type DialogueView } from '@rpg/engine';
import { GameState } from '@rpg/engine';
import { DIALOGUES } from '../dialogues';

/** Заглушка view: запоминает показанные реплики. */
function stubView(): DialogueView & { shown: string[] } {
    const shown: string[] = [];
    return {
        shown,
        show: (n: { text: string }) => void shown.push(n.text),
        hide: () => undefined
    };
}

describe('trader_repeat — ветка по вару motes', () => {
    it('без мотов — только базовая реплика', () => {
        const view = stubView();
        const runner = new DialogueRunner(new GameState(), view);
        runner.start(DIALOGUES.trader_repeat);
        runner.advance();
        expect(view.shown).toHaveLength(1);
        expect(view.shown[0]).toContain('Звони тихо');
    });

    it('с мотами (motes >= 1) — добавляется реплика о мота́х', () => {
        const view = stubView();
        const state = new GameState();
        state.setVar('motes', 2);
        const runner = new DialogueRunner(state, view);
        runner.start(DIALOGUES.trader_repeat);
        runner.advance();
        expect(view.shown).toHaveLength(2);
        expect(view.shown[1]).toContain('Моты');
    });
});