boardgame-core/tests/samples/slay-the-spire-like/dialogue/encounters.test.ts

54 lines
2.1 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import encounters from '@/samples/slay-the-spire-like/dialogue/encounters/encounters.yarnproject';
describe('encounters.yarnproject import', () => {
it('should load the yarnproject with expected project metadata', () => {
expect(encounters.project.projectName).toBe('encounters');
expect(encounters.project.baseLanguage).toBe('en');
expect(encounters.project.authorName).toContain('hyper');
expect(encounters.project.projectFileVersion).toBe(4);
});
it('should have sourceFiles configured', () => {
expect(encounters.project.sourceFiles).toContain('**/*.yarn');
});
it('should have a valid baseDir', () => {
expect(typeof encounters.baseDir).toBe('string');
expect(encounters.baseDir.length).toBeGreaterThan(0);
});
it('should compile nodes from .yarn files', () => {
const nodeTitles = Object.keys(encounters.program.nodes);
expect(nodeTitles.length).toBeGreaterThan(0);
});
it('should contain expected nodes from story.yarn', () => {
const nodeTitles = Object.keys(encounters.program.nodes);
expect(nodeTitles).toContain('Start');
expect(nodeTitles).toContain('Scene1');
expect(nodeTitles).toContain('Scene2');
expect(nodeTitles).toContain('Scene3');
expect(nodeTitles).toContain('Scene4');
});
it('should have instructions in each node', () => {
for (const [title, node] of Object.entries(encounters.program.nodes)) {
if ('instructions' in node && Array.isArray((node as any).instructions)) {
expect((node as any).instructions.length).toBeGreaterThan(0);
}
}
});
it('should have Start node with jump instruction to Scene1', () => {
const startNode = encounters.program.nodes['Start'];
if ('instructions' in startNode) {
const jumpInstruction = startNode.instructions.find(
(instr) => instr.op === 'jump',
);
expect(jumpInstruction).toBeDefined();
expect(jumpInstruction!.target).toBe('Scene1');
}
});
});