40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import {
|
|
defaultPathNormalize,
|
|
isProtectedPath,
|
|
DEFAULT_PROTECTED_PATTERNS,
|
|
} from './shell-content-rules.mjs';
|
|
|
|
describe('defaultPathNormalize', () => {
|
|
it('forward-slashes backslashes and strips quotes', () => {
|
|
expect(defaultPathNormalize('"a\\b\\c"')).toBe('a/b/c');
|
|
});
|
|
it('returns empty string for non-string', () => {
|
|
expect(defaultPathNormalize(null)).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('isProtectedPath', () => {
|
|
it.each([
|
|
'.env',
|
|
'app/.env.production',
|
|
'node_modules/shell-quote/index.js',
|
|
'CLAUDE.md',
|
|
'docs/Pravila_raboty_Claude_v1_1.md',
|
|
'memory/feedback.md',
|
|
'tools/dep-checksums.json',
|
|
'~/.claude/runtime/router-state-x.json',
|
|
'~/.claude/settings.json',
|
|
])('protects %s', (p) => {
|
|
expect(isProtectedPath(p, defaultPathNormalize, DEFAULT_PROTECTED_PATTERNS)).toBe(true);
|
|
});
|
|
|
|
it.each([
|
|
'app/Models/Deal.php',
|
|
'docs/notes.md',
|
|
'tools/enforce-router-gate.mjs',
|
|
])('allows %s', (p) => {
|
|
expect(isProtectedPath(p, defaultPathNormalize, DEFAULT_PROTECTED_PATTERNS)).toBe(false);
|
|
});
|
|
});
|