|
| 1 | +import { describe, it, expect } from 'vitest' |
| 2 | +import { getEstimateSize } from '../../src/runtime/utils/virtualizer' |
| 3 | + |
| 4 | +describe('getEstimateSize', () => { |
| 5 | + it('returns the height for each built-in size', () => { |
| 6 | + expect(getEstimateSize([{ label: 'foo' }], 'xs')(0)).toBe(24) |
| 7 | + expect(getEstimateSize([{ label: 'foo' }], 'xl')(0)).toBe(40) |
| 8 | + }) |
| 9 | + |
| 10 | + it('falls back to the `md` size for a custom theme size', () => { |
| 11 | + expect(getEstimateSize([{ label: 'foo' }], 'xxs')(0)).toBe(32) |
| 12 | + }) |
| 13 | + |
| 14 | + it('falls back to the `md` size for a custom theme size with a description', () => { |
| 15 | + const items = [{ label: 'foo', description: 'bar' }] |
| 16 | + |
| 17 | + expect(getEstimateSize(items, 'xxs', 'description')(0)).toBe(52) |
| 18 | + expect(getEstimateSize(items, 'xxs', undefined, true)(0)).toBe(52) |
| 19 | + }) |
| 20 | + |
| 21 | + it('uses the larger size only for items that have a description', () => { |
| 22 | + const items = [{ label: 'foo', description: 'bar' }, { label: 'baz' }] |
| 23 | + const estimateSize = getEstimateSize(items, 'md', 'description') |
| 24 | + |
| 25 | + expect(estimateSize(0)).toBe(52) |
| 26 | + expect(estimateSize(1)).toBe(32) |
| 27 | + }) |
| 28 | +}) |
0 commit comments