mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { getEstimateSize } from '../../src/runtime/utils/virtualizer'
|
|
|
|
describe('getEstimateSize', () => {
|
|
it('returns the height for each built-in size', () => {
|
|
expect(getEstimateSize([{ label: 'foo' }], 'xs')(0)).toBe(24)
|
|
expect(getEstimateSize([{ label: 'foo' }], 'xl')(0)).toBe(40)
|
|
})
|
|
|
|
it('falls back to the `md` size for a custom theme size', () => {
|
|
expect(getEstimateSize([{ label: 'foo' }], 'xxs')(0)).toBe(32)
|
|
})
|
|
|
|
it('falls back to the `md` size for a custom theme size with a description', () => {
|
|
const items = [{ label: 'foo', description: 'bar' }]
|
|
|
|
expect(getEstimateSize(items, 'xxs', 'description')(0)).toBe(52)
|
|
expect(getEstimateSize(items, 'xxs', undefined, true)(0)).toBe(52)
|
|
})
|
|
|
|
it('uses the larger size only for items that have a description', () => {
|
|
const items = [{ label: 'foo', description: 'bar' }, { label: 'baz' }]
|
|
const estimateSize = getEstimateSize(items, 'md', 'description')
|
|
|
|
expect(estimateSize(0)).toBe(52)
|
|
expect(estimateSize(1)).toBe(32)
|
|
})
|
|
})
|