feat(bake-sprite): end-to-end sprite-mode orchestrator + CLI dispatch
This commit is contained in:
32
tests/bake-sprite-determinism.test.js
Normal file
32
tests/bake-sprite-determinism.test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const os = require('node:os');
|
||||
const { bake } = require('../src/bake');
|
||||
|
||||
const FRESH = path.resolve(__dirname, 'fixtures/sprite-fresh');
|
||||
|
||||
test('bake sprite: re-bake produces byte-identical PNG + UV-JSON', async (t) => {
|
||||
const tmpA = fs.mkdtempSync(path.join(os.tmpdir(), 'det-a-'));
|
||||
const tmpB = fs.mkdtempSync(path.join(os.tmpdir(), 'det-b-'));
|
||||
t.after(() => {
|
||||
fs.rmSync(tmpA, { recursive: true, force: true });
|
||||
fs.rmSync(tmpB, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
const opts = { mode: 'sprite', inDir: FRESH, atlasId: 'det', padPx: 0 };
|
||||
await bake({ ...opts, outDir: tmpA });
|
||||
await bake({ ...opts, outDir: tmpB });
|
||||
|
||||
const pngA = fs.readFileSync(path.join(tmpA, 'det/sprites.diffuse.atlas.png'));
|
||||
const pngB = fs.readFileSync(path.join(tmpB, 'det/sprites.diffuse.atlas.png'));
|
||||
const uvA = fs.readFileSync(path.join(tmpA, 'det/sprites.uv.json'), 'utf8');
|
||||
const uvB = fs.readFileSync(path.join(tmpB, 'det/sprites.uv.json'), 'utf8');
|
||||
const lockA = fs.readFileSync(path.join(tmpA, 'det/sprites.atlas.lock.json'), 'utf8');
|
||||
const lockB = fs.readFileSync(path.join(tmpB, 'det/sprites.atlas.lock.json'), 'utf8');
|
||||
|
||||
assert.deepStrictEqual(pngA, pngB);
|
||||
assert.strictEqual(uvA, uvB);
|
||||
assert.strictEqual(lockA, lockB);
|
||||
});
|
||||
Reference in New Issue
Block a user