Files

45 lines
1.4 KiB
TypeScript

import { createHash } from 'node:crypto';
import { existsSync, readFileSync, statSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
function sha256(path: string): string {
return createHash('sha256').update(readFileSync(path)).digest('hex');
}
describe('decoder staging', () => {
it('stages only the single-thread IFC runtime', () => {
expect(
existsSync(
resolve(projectRoot, 'apps/viewer-3d/public/web-ifc/web-ifc-mt.wasm'),
),
).toBe(false);
});
it('does not stage decoder copies already bundled by Three.js', () => {
for (const directory of ['draco', 'basis']) {
expect(
existsSync(resolve(projectRoot, 'apps/viewer-3d/public', directory)),
).toBe(false);
}
});
it('copies the IFC binary byte-for-byte without executable permission', () => {
const ifcRoot = dirname(fileURLToPath(import.meta.resolve('web-ifc')));
const pairs = [
[
resolve(ifcRoot, 'web-ifc.wasm'),
resolve(projectRoot, 'apps/viewer-3d/public/web-ifc/web-ifc.wasm'),
],
];
for (const [source, staged] of pairs) {
expect(sha256(staged)).toBe(sha256(source));
expect(statSync(staged).mode & 0o111).toBe(0);
}
});
});