import { describe, expect, it } from 'vitest';
import { pulledCleanly } from './pullResults';

const paths = ['a.txt', 'b.txt', 'c.txt'];

describe('pulledCleanly', () => {
  it('keeps every path on a clean result', () => {
    expect(pulledCleanly(paths, { ok: true, errors: [] })).toEqual(paths);
  });

  it('drops exactly the per-file failures', () => {
    const result = { ok: false, errors: [{ path: 'b.txt', error: 'Server error (404).' }] };
    expect(pulledCleanly(paths, result)).toEqual(['a.txt', 'c.txt']);
  });

  it('trusts nothing after a transport-level failure', () => {
    expect(pulledCleanly(paths, { ok: false, error: 'invoke rejected' })).toEqual([]);
    expect(pulledCleanly(paths, undefined)).toEqual([]);
  });
});
