mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-16 13:55:51 -07:00
7a1450ddb7
- Add the Ctrl+Alt+A shortcut and dedicated overlay modal - Share queue, sources, and watch history while isolating browser state
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
function buildScript(name: string): string {
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(path.join(import.meta.dir, '..', 'package.json'), 'utf8'),
|
|
) as { scripts: Record<string, string> };
|
|
return packageJson.scripts[name] ?? '';
|
|
}
|
|
|
|
test('build:syncui bundles the sandboxed preload and keeps Electron external', () => {
|
|
const command = buildScript('build:syncui');
|
|
|
|
assert.match(command, /src\/preload-syncui\.ts/);
|
|
assert.match(command, /--bundle/);
|
|
assert.match(command, /--external:electron/);
|
|
assert.match(command, /--outfile=dist\/preload-syncui\.js/);
|
|
});
|
|
|
|
test('build:animeui bundles the sandboxed preload and keeps Electron external', () => {
|
|
const command = buildScript('build:animeui');
|
|
const sharedPreloadSource = fs.readFileSync(
|
|
path.join(import.meta.dir, '..', 'src', 'preload-anime-browser-api.ts'),
|
|
'utf8',
|
|
);
|
|
|
|
// The preload imports IPC_CHANNELS, so it must be bundled rather than
|
|
// emitted by plain tsc with a relative runtime require.
|
|
assert.match(command, /src\/preload-animeui\.ts/);
|
|
assert.match(command, /--bundle/);
|
|
assert.match(command, /--external:electron/);
|
|
assert.match(command, /--outfile=dist\/preload-animeui\.js/);
|
|
// The standalone Anime window uses Electron's sandboxed preload runtime,
|
|
// which exposes `electron` but cannot require arbitrary Node built-ins.
|
|
assert.doesNotMatch(sharedPreloadSource, /from ['"]node:/);
|
|
});
|
|
|
|
test('build:animeui runs as part of the top-level build', () => {
|
|
assert.match(buildScript('build'), /bun run build:animeui/);
|
|
});
|