import { describe, expect, it } from 'vitest';
import {
  isProjectCodeTextPath,
  isProjectReadableTextPath,
  isLearnitiveEditableTextPath,
} from '../text-file-policy';

describe('isLearnitiveEditableTextPath', () => {
  it.each([
    'main.tex',
    'chapters/results.TEX',
    'references.bib',
    'journal.cls',
    'custom.sty',
    'plain.bst',
    'legacy.ltx',
    'notes.txt',
  ])('accepts %s', (path) => {
    expect(isLearnitiveEditableTextPath(path)).toBe(true);
  });

  it.each(['figure.png', 'paper.pdf', 'legacy.eps', 'Makefile', '.git/HEAD'])(
    'rejects %s',
    (path) => {
      expect(isLearnitiveEditableTextPath(path)).toBe(false);
    },
  );
});


describe('isProjectCodeTextPath', () => {
  it.each([
    'analysis.py', 'src/model.c', 'src/model.cpp', 'include/model.hpp',
    'data/results.csv', 'data/results.tsv', 'config.json', 'config.yaml',
    'pyproject.toml', 'scripts/run.sh',
  ])('accepts scientific/code text %s', (path) => {
    expect(isProjectCodeTextPath(path)).toBe(true);
  });

  it.each(['main.tex', 'paper.md', 'figure.png', 'dataset.npy', 'paper.pdf'])(
    'does not route %s through the generic code editor',
    (path) => expect(isProjectCodeTextPath(path)).toBe(false),
  );
});

describe('isProjectReadableTextPath', () => {
  it.each([
    'main.tex',
    'references.bib',
    'analysis/model.py',
    'analysis/model.R',
    'src/model.cpp',
    'data/results.csv',
    'config.json',
    'notes/method.md',
  ])('allows research-readable text %s', (path) => {
    expect(isProjectReadableTextPath(path)).toBe(true);
  });

  it.each(['paper.pdf', 'figure.png', 'dataset.npy', '.git/index'])(
    'keeps binary/opaque project data unreadable: %s',
    (path) => expect(isProjectReadableTextPath(path)).toBe(false),
  );
});
