30 lines
975 B
TypeScript
30 lines
975 B
TypeScript
import { describe, expect, test } from 'bun:test';
|
|||
|
|
|
||
|
|
import { isPathWithinProject } from './utils';
|
||
|
|
|
||
|
|
describe('isPathWithinProject', () => {
|
||
|
|
test('matches child directories for root projects', () => {
|
||
|
|
expect(isPathWithinProject('/workspace/app', '/')).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('matches exact project directories', () => {
|
||
|
|
expect(isPathWithinProject('/workspace/app', '/workspace/app')).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('does not match sibling directory prefixes', () => {
|
||
|
|
expect(isPathWithinProject('/workspace/app2', '/workspace/app')).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('returns false when directory is null', () => {
|
||
|
|
expect(isPathWithinProject(null, '/workspace/app')).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('returns false when projectPath is null', () => {
|
||
|
|
expect(isPathWithinProject('/workspace/app', null)).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('matches deep child directories', () => {
|
||
|
|
expect(isPathWithinProject('/workspace/app/sub/dir', '/workspace/app')).toBe(true);
|
||
|
|
});
|
||
|
|
});
|