import { annotateLocalFilePath, resolveLocalFilePath } from './local-file-path.rules';

describe('local file path rules', () => {
  it('prefers an existing path property on the file', () => {
    const file = new File(['video'], 'clip.mp4', { type: 'video/mp4' });

    Object.defineProperty(file, 'path', { value: '/tmp/clip.mp4' });

    expect(resolveLocalFilePath(file)).toBe('/tmp/clip.mp4');
  });

  it('resolves drag-and-drop files through Electron getPathForFile', () => {
    const file = new File(['video'], 'clip.mp4', { type: 'video/mp4' });

    expect(resolveLocalFilePath(file, {
      getPathForFile: () => '/home/ludde/Videos/clip.mp4'
    })).toBe('/home/ludde/Videos/clip.mp4');
  });

  it('annotates a file object with the resolved path', () => {
    const file = new File(['video'], 'clip.mp4', { type: 'video/mp4' });
    const annotated = annotateLocalFilePath(file, {
      getPathForFile: () => '/home/ludde/Videos/clip.mp4'
    });

    expect(resolveLocalFilePath(annotated)).toBe('/home/ludde/Videos/clip.mp4');
  });
});
