Files
sporel-tool-atlas-baker/tests/scan.test.js
Axel Meyer b64e3e87a9 Init atlas-baker tool with source-dir scan and pair-detection
Creates the sporel-tool-atlas-baker Node CLI scaffold and the first
phase of the bake pipeline: scan a source directory for *_diffuse.png
files, pair them with optional *_height.png companions, and return
alphabetically-sorted sources for deterministic re-bakes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:38:42 +02:00

29 lines
1.1 KiB
JavaScript

// tests/scan.test.js
const { test } = require('node:test');
const assert = require('node:assert');
const path = require('node:path');
const { scanSourceDir } = require('../src/scan');
const FIXTURE_DIR = path.resolve(__dirname, 'fixtures/small-fresh');
test('scan: 3 diffuse + 1 paired height', () => {
const { sources, errors } = scanSourceDir(FIXTURE_DIR);
assert.deepStrictEqual(errors, []);
assert.strictEqual(sources.length, 3);
// Sorted alphabetically
assert.strictEqual(sources[0].name, 'grass');
assert.strictEqual(sources[1].name, 'stone');
assert.strictEqual(sources[2].name, 'water');
// grass + stone have no height
assert.strictEqual(sources[0].heightPath, null);
assert.strictEqual(sources[1].heightPath, null);
// water has height
assert.ok(sources[2].heightPath?.endsWith('water_height.png'));
});
test('scan: empty dir -> error', () => {
const { sources, errors } = scanSourceDir(path.resolve(__dirname, 'fixtures/_empty'));
assert.strictEqual(sources.length, 0);
assert.ok(errors.length > 0);
});