Files
waggle-os/packages/hive-mind-shim-core/tests/main-module.test.ts
Oleg Maslov b20b138fe4 moving
2026-09-02 10:14:22 +02:00

18 lines
769 B
TypeScript

import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { describe, expect, it } from 'vitest';
import { isDirectExecution } from '../src/main-module.js';
describe('isDirectExecution', () => {
it('matches an argv filesystem path to its canonical file URL', () => {
const scriptPath = resolve('fixtures', 'hook #1.js');
expect(isDirectExecution(pathToFileURL(scriptPath).href, scriptPath)).toBe(true);
});
it('rejects a different entrypoint or missing argv path', () => {
const modulePath = resolve('fixtures', 'hook.js');
expect(isDirectExecution(pathToFileURL(modulePath).href, resolve('fixtures', 'other.js'))).toBe(false);
expect(isDirectExecution(pathToFileURL(modulePath).href, '')).toBe(false);
});
});