import { describe, expect, it } from 'vitest'
import { parsePageQuery } from './useListPageQuery'
import { parseDetailTabQuery } from './useDetailTabQuery'

describe('parsePageQuery', () => {
  it('defaults to page 1', () => {
    expect(parsePageQuery(undefined)).toBe(1)
    expect(parsePageQuery('')).toBe(1)
    expect(parsePageQuery('0')).toBe(1)
    expect(parsePageQuery('abc')).toBe(1)
  })

  it('parses positive integers', () => {
    expect(parsePageQuery('3')).toBe(3)
    expect(parsePageQuery(['7'])).toBe(7)
  })
})

describe('parseDetailTabQuery', () => {
  it('falls back to the default tab', () => {
    expect(parseDetailTabQuery(undefined, ['balances', 'transfers'] as const, 'balances')).toBe('balances')
    expect(parseDetailTabQuery('unknown', ['balances', 'transfers'] as const, 'balances')).toBe('balances')
  })

  it('accepts valid tabs', () => {
    expect(parseDetailTabQuery('transfers', ['balances', 'transfers'] as const, 'balances')).toBe('transfers')
  })
})
