import { describe, expect, it } from 'vitest';
import { mediaDetailPath } from './mediaKinds';
import type { LibraryBrowseItem } from '../api';

function episodeItem(overrides: Partial<LibraryBrowseItem>): LibraryBrowseItem {
  return {
    artwork: '',
    id: 91,
    mediaType: 'Episode',
    title: 'Pilot',
    ...overrides
  } as unknown as LibraryBrowseItem;
}

describe('mediaDetailPath', () => {
  it('routes an episode with a seasonId to the season detail page, anchored to the episode (#220)', () => {
    const item = episodeItem({ seasonId: 8 } as Partial<LibraryBrowseItem>);
    expect(mediaDetailPath(item)).toBe('/app/media/seasons/8#episode-91');
  });

  it('returns null for an episode with no seasonId', () => {
    const item = episodeItem({});
    expect(mediaDetailPath(item)).toBeNull();
  });

  it('still routes a movie to its detail page', () => {
    const item = {
      artwork: '',
      id: 5,
      mediaType: 'Movie',
      title: 'Blade Runner'
    } as unknown as LibraryBrowseItem;
    expect(mediaDetailPath(item)).toBe('/app/media/movies/5');
  });
});
