moving
This commit is contained in:
17
packages/hive-mind-shim-core/tests/main-module.test.ts
Normal file
17
packages/hive-mind-shim-core/tests/main-module.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user