import { describe, expect, it } from 'vitest'
import { replySchema, listQuerySchema } from './review.schemas'

describe('review schemas', () => {
  it('requires a non-empty company reply', () => {
    expect(() => replySchema.parse({ companyReply: '' })).toThrow()
    expect(replySchema.parse({ companyReply: 'Thank you for the feedback.' })).toEqual({ companyReply: 'Thank you for the feedback.' })
  })

  it('coerces rating query values to bounded integers', () => {
    expect(listQuerySchema.parse({ rating: '5', page: '3', pageSize: '10' })).toEqual({
      rating: 5,
      page: 3,
      pageSize: 10,
    })
  })

  it('rejects ratings outside the public five-star scale', () => {
    expect(() => listQuerySchema.parse({ rating: '0' })).toThrow()
    expect(() => listQuerySchema.parse({ rating: '6' })).toThrow()
  })

  it('defaults pagination when filters are omitted', () => {
    expect(listQuerySchema.parse({})).toEqual({ page: 1, pageSize: 20 })
  })
})
