23 lines
918 B
TypeScript
23 lines
918 B
TypeScript
/**
|
|
* Pure-function tests for shouldConfirmWrite.
|
|
* No DOM render needed — these run in node env.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { shouldConfirmWrite } from './app-bridge';
|
|
|
|
describe('shouldConfirmWrite', () => {
|
|
it('returns false when autoApprove=true (always bypass confirm)', () => {
|
|
// Even a path that would normally require confirm is bypassed.
|
|
expect(shouldConfirmWrite('my-app', 'some/arbitrary/file.txt', true)).toBe(false);
|
|
});
|
|
|
|
it('returns false when path is under output/ (allowlisted, no confirm needed)', () => {
|
|
expect(shouldConfirmWrite('my-app', 'output/report.csv', false)).toBe(false);
|
|
});
|
|
|
|
it('returns true when autoApprove=false and path is NOT allowlisted', () => {
|
|
// A path not under output/ or apps/{appName}/data/ must trigger a confirm.
|
|
expect(shouldConfirmWrite('my-app', 'some/arbitrary/file.txt', false)).toBe(true);
|
|
});
|
|
});
|