2026-05-16 09:46:05 -04:00
|
|
|
import { describe, expect, test } from 'bun:test';
|
2026-07-13 23:18:12 +03:00
|
|
|
import { isPathWithinProject } from './utils';
|
2026-05-16 09:46:05 -04:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|