import { describe, expect, test } from 'vitest';
import { qk } from './queries';

describe('qk key generators', () => {
  test('artists key includes sort discriminator', () => {
    expect(qk.artists('alpha')).toEqual(['artists', { sort: 'alpha' }]);
    expect(qk.artists('newest')).toEqual(['artists', { sort: 'newest' }]);
  });

  test('artist key tuple', () => {
    expect(qk.artist('abc')).toEqual(['artist', 'abc']);
  });

  test('album key tuple', () => {
    expect(qk.album('xyz')).toEqual(['album', 'xyz']);
  });
});

describe('qk search keys', () => {
  test('search summary key includes q', () => {
    expect(qk.search('foo')).toEqual(['search', { q: 'foo' }]);
  });
  test('searchArtists key includes q', () => {
    expect(qk.searchArtists('foo')).toEqual(['searchArtists', { q: 'foo' }]);
  });
  test('searchAlbums key includes q', () => {
    expect(qk.searchAlbums('foo')).toEqual(['searchAlbums', { q: 'foo' }]);
  });
  test('searchTracks key includes q', () => {
    expect(qk.searchTracks('foo')).toEqual(['searchTracks', { q: 'foo' }]);
  });
});

describe('qk M6a keys', () => {
  test('M6a query keys are stable', () => {
    expect(qk.home()).toEqual(['home']);
    expect(qk.albumsAlpha()).toEqual(['albumsAlpha']);
    expect(qk.artistTracks('a1')).toEqual(['artistTracks', 'a1']);
  });
});
