|
|
|
@@ -14,14 +14,14 @@ describe('loadYarnProject', () => {
|
|
|
|
|
expect(result.project.projectName).toBe('Simple Test Project');
|
|
|
|
|
expect(result.project.sourceFiles).toEqual(['**/*.yarn']);
|
|
|
|
|
expect(result.project.baseLanguage).toBe('en');
|
|
|
|
|
expect(result.yarnFiles.length).toBeGreaterThan(0);
|
|
|
|
|
expect(Object.keys(result.program.nodes).length).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should parse all yarn files in simple project', async () => {
|
|
|
|
|
it('should compile all yarn files in simple project', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/simple/.yarnproject');
|
|
|
|
|
const result = await loadYarnProject(projectPath);
|
|
|
|
|
|
|
|
|
|
const titles = result.yarnFiles.flatMap(f => f.document.nodes.map(n => n.title));
|
|
|
|
|
const titles = Object.keys(result.program.nodes);
|
|
|
|
|
expect(titles).toContain('Start');
|
|
|
|
|
expect(titles).toContain('Greeting');
|
|
|
|
|
expect(titles).toContain('AnotherNode');
|
|
|
|
@@ -35,7 +35,7 @@ describe('loadYarnProject', () => {
|
|
|
|
|
expect(result.project.baseLanguage).toBe('en');
|
|
|
|
|
expect(result.project.localisation).toBeDefined();
|
|
|
|
|
expect(result.project.localisation!['zh-Hans']).toBeDefined();
|
|
|
|
|
expect(result.yarnFiles.length).toBeGreaterThan(0);
|
|
|
|
|
expect(Object.keys(result.program.nodes).length).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should load a complex project with multiple patterns', async () => {
|
|
|
|
@@ -48,51 +48,21 @@ describe('loadYarnProject', () => {
|
|
|
|
|
expect(result.project.sourceFiles).toContain('scripts/**/*.yarn');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should exclude files matching excludeFiles patterns', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/complex/.yarnproject');
|
|
|
|
|
const result = await loadYarnProject(projectPath);
|
|
|
|
|
|
|
|
|
|
// Check that backup file is excluded
|
|
|
|
|
const backupFiles = result.yarnFiles.filter(f =>
|
|
|
|
|
f.relativePath.includes('backup'),
|
|
|
|
|
);
|
|
|
|
|
expect(backupFiles).toHaveLength(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should include files from multiple source patterns', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/complex/.yarnproject');
|
|
|
|
|
const result = await loadYarnProject(projectPath);
|
|
|
|
|
|
|
|
|
|
const relativePaths = result.yarnFiles.map(f => f.relativePath);
|
|
|
|
|
|
|
|
|
|
// Should include dialogue files
|
|
|
|
|
expect(relativePaths.some(p => p.includes('dialogue'))).toBe(true);
|
|
|
|
|
// Should include script files
|
|
|
|
|
expect(relativePaths.some(p => p.includes('scripts'))).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should parse yarn documents correctly', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/simple/.yarnproject');
|
|
|
|
|
const result = await loadYarnProject(projectPath);
|
|
|
|
|
|
|
|
|
|
const startNode = result.yarnFiles
|
|
|
|
|
.flatMap(f => f.document.nodes)
|
|
|
|
|
.find(n => n.title === 'Start');
|
|
|
|
|
|
|
|
|
|
const startNode = result.program.nodes['Start'];
|
|
|
|
|
expect(startNode).toBeDefined();
|
|
|
|
|
expect(startNode!.body.length).toBeGreaterThan(0);
|
|
|
|
|
expect(startNode && 'instructions' in startNode ? startNode.instructions.length : 0).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should handle nodes with tags', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/simple/.yarnproject');
|
|
|
|
|
const result = await loadYarnProject(projectPath);
|
|
|
|
|
|
|
|
|
|
const greetingNode = result.yarnFiles
|
|
|
|
|
.flatMap(f => f.document.nodes)
|
|
|
|
|
.find(n => n.title === 'Greeting');
|
|
|
|
|
|
|
|
|
|
const greetingNode = result.program.nodes['Greeting'];
|
|
|
|
|
expect(greetingNode).toBeDefined();
|
|
|
|
|
expect(greetingNode!.nodeTags).toContain('greeting');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should throw LoadError for non-existent file', async () => {
|
|
|
|
@@ -104,7 +74,6 @@ describe('loadYarnProject', () => {
|
|
|
|
|
it('should throw error for invalid JSON', async () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/invalid/.yarnproject');
|
|
|
|
|
|
|
|
|
|
// This will fail because the fixture doesn't exist
|
|
|
|
|
await expect(loadYarnProject(projectPath)).rejects.toThrow();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@@ -115,14 +84,14 @@ describe('loadYarnProjectSync', () => {
|
|
|
|
|
const result = loadYarnProjectSync(projectPath);
|
|
|
|
|
|
|
|
|
|
expect(result.project.projectFileVersion).toBe(4);
|
|
|
|
|
expect(result.yarnFiles.length).toBeGreaterThan(0);
|
|
|
|
|
expect(Object.keys(result.program.nodes).length).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should parse all yarn files synchronously', () => {
|
|
|
|
|
it('should compile all yarn files synchronously', () => {
|
|
|
|
|
const projectPath = resolve(__dirname, 'fixtures/simple/.yarnproject');
|
|
|
|
|
const result = loadYarnProjectSync(projectPath);
|
|
|
|
|
|
|
|
|
|
const titles = result.yarnFiles.flatMap(f => f.document.nodes.map(n => n.title));
|
|
|
|
|
const titles = Object.keys(result.program.nodes);
|
|
|
|
|
expect(titles).toContain('Start');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|