import { describe, expect, it } from 'vitest';
import { parseMediaSubRoute } from './routing';

describe('parseMediaSubRoute', () => {
  it('returns null for the base media path', () => {
    expect(parseMediaSubRoute('/app/media')).toBeNull();
    expect(parseMediaSubRoute('/app/media/')).toBeNull();
  });

  it('parses the four detail kinds', () => {
    expect(parseMediaSubRoute('/app/media/movies/5')).toEqual({ id: 5, kind: 'movie' });
    expect(parseMediaSubRoute('/app/media/shows/6')).toEqual({ id: 6, kind: 'show' });
    expect(parseMediaSubRoute('/app/media/seasons/7')).toEqual({ id: 7, kind: 'season' });
    expect(parseMediaSubRoute('/app/media/artists/8')).toEqual({ id: 8, kind: 'artist' });
  });

  it('parses the image browser path', () => {
    expect(parseMediaSubRoute('/app/media/images/browser')).toEqual({ kind: 'images' });
  });

  it('rejects unknown kinds and non-numeric ids', () => {
    expect(parseMediaSubRoute('/app/media/widgets/5')).toBeNull();
    expect(parseMediaSubRoute('/app/media/movies/abc')).toBeNull();
    expect(parseMediaSubRoute('/app/media/movies/0')).toBeNull();
    expect(parseMediaSubRoute('/app/media/movies')).toBeNull();
    expect(parseMediaSubRoute('/app/media/movies/5/extra')).toBeNull();
  });
});
