index.test.ts24 lines · main
| 1 | import { describe, expect, it } from 'vitest' |
| 2 | |
| 3 | import { resolveColumnsForWidth } from './index' |
| 4 | |
| 5 | describe('resolveColumnsForWidth', () => { |
| 6 | it('caps the visible count by maxColumns', () => { |
| 7 | expect(resolveColumnsForWidth({ width: 1600, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(4) |
| 8 | }) |
| 9 | |
| 10 | it('reduces visible items as the container narrows', () => { |
| 11 | expect(resolveColumnsForWidth({ width: 1200, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(4) |
| 12 | expect(resolveColumnsForWidth({ width: 900, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(3) |
| 13 | expect(resolveColumnsForWidth({ width: 700, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(2) |
| 14 | expect(resolveColumnsForWidth({ width: 500, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(1) |
| 15 | }) |
| 16 | |
| 17 | it('always returns at least one visible slot', () => { |
| 18 | expect(resolveColumnsForWidth({ width: 0, maxColumns: 4, minWidth: 280, gap: 16 })).toBe(1) |
| 19 | }) |
| 20 | |
| 21 | it('returns a safe value when minWidth and gap are both zero', () => { |
| 22 | expect(resolveColumnsForWidth({ width: 1600, maxColumns: 4, minWidth: 0, gap: 0 })).toBe(4) |
| 23 | }) |
| 24 | }) |