Files
appRobotVideoControls/test/02_build_scene.test.js
2026-05-23 10:42:13 +02:00

44 lines
1.6 KiB
JavaScript

// test/02_build_scene_json.test.js
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
describe('Build Scene JSON Script', () => {
const scriptPath = 'programs/02_build_scene_json.py';
const timestamp = 1778819665744;
const testDir = './test/data/screenShots';
test('should exist and be executable', () => {
expect(fs.existsSync(scriptPath)).toBe(true);
});
test('should build scene JSON with timestamp parameter', () => {
// Überprüfe, ob der Test-Ordner existiert
expect(fs.existsSync(testDir)).toBe(true);
// Führe das Python-Skript mit den korrekten Parametern aus
const cmd = `python ${scriptPath} -timestamp ${timestamp} -dir ${testDir}`;
try {
//execSync(cmd, { stdio: 'inherit' });
//execSync(cmd, { stdio: 'pipe' });
execSync(cmd);
console.log("TEST START", process.pid, Date.now());
} catch (error) {
throw new Error(`Failed to build scene JSON: ${error.message}`);
}
// Überprüfe, ob die erwartete Ausgabedatei erstellt wurde
const expectedJsonFile = `./test/data/screenShots/scene_${timestamp}.json`;
expect(fs.existsSync(expectedJsonFile)).toBe(true);
// Prüfe den Inhalt der JSON-Datei
const jsonData = JSON.parse(fs.readFileSync(expectedJsonFile, 'utf8'));
expect(jsonData).toBeDefined();
expect(typeof jsonData).toBe('object');
});
test('should handle timestamp parameter correctly', () => {
// Überprüfe, ob der Timestamp korrekt verarbeitet wird
expect(timestamp).toBe(1778819665744);
});
});