import { describe, it, expect } from 'vitest'
import { rangeLabel, isRangeSelected } from '@/features/listings/composables/useFilterOptions'

describe('useFilterOptions', () => {
  describe('rangeLabel', () => {
    it('应该返回双向范围标签', () => {
      expect(rangeLabel(100, 500, '哈夫币')).toBe('100-500')
    })

    it('应该返回最小值+标签', () => {
      expect(rangeLabel(500, undefined, '哈夫币')).toBe('500+')
    })

    it('应该返回最大值标签', () => {
      expect(rangeLabel(undefined, 500, '哈夫币')).toBe('≤500')
    })

    it('应该返回默认标签', () => {
      expect(rangeLabel(undefined, undefined, '哈夫币')).toBe('哈夫币')
    })
  })

  describe('isRangeSelected', () => {
    it('应该正确判断范围是否选中', () => {
      expect(isRangeSelected(100, 500, 100, 500)).toBe(true)
      expect(isRangeSelected(100, 500, 200, 500)).toBe(false)
      expect(isRangeSelected(undefined, undefined, undefined, undefined)).toBe(true)
    })
  })
})
