import { describe, expect, it } from 'vitest';
import { mapProjectGitStatus } from '../status';

describe('mapProjectGitStatus', () => {
  it('does not report a staged file as modified again when index and workdir match', () => {
    expect(mapProjectGitStatus('main.tex', 1, 2, 2)).toEqual({
      staged: { path: 'main.tex', status: 'modified', staged: true },
      unstaged: undefined,
    });
  });

  it('reports a staged file that was edited again in both buckets', () => {
    expect(mapProjectGitStatus('main.tex', 1, 2, 3)).toEqual({
      staged: { path: 'main.tex', status: 'modified', staged: true },
      unstaged: { path: 'main.tex', status: 'modified', staged: false },
    });
  });

  it('reports a new untracked file only as unstaged', () => {
    expect(mapProjectGitStatus('figures/result.png', 0, 2, 0)).toEqual({
      staged: undefined,
      unstaged: {
        path: 'figures/result.png',
        status: 'untracked',
        staged: false,
      },
    });
  });

  it('reports a working-tree deletion against HEAD', () => {
    expect(mapProjectGitStatus('old.tex', 1, 0, 1)).toEqual({
      staged: undefined,
      unstaged: { path: 'old.tex', status: 'deleted', staged: false },
    });
  });
});
