| 1 | import { describe, expect, it } from 'vitest' |
| 2 | import { limitBrowsePreviewIds } from '../../../src/renderer/src/components/session-detail/browse/browse-preview-utils' |
| 3 | |
| 4 | describe('limitBrowsePreviewIds', () => { |
| 5 | it('keeps all visible preview ids within the browse cache limit', () => { |
| 6 | const ids = new Set(['page-1', 'page-2', 'page-3']) |
| 7 | |
| 8 | expect(Array.from(limitBrowsePreviewIds(ids, 20))).toEqual(['page-1', 'page-2', 'page-3']) |
| 9 | }) |
| 10 | |
| 11 | it('keeps the first visible preview ids when the cache is full', () => { |
| 12 | const ids = new Set(Array.from({ length: 24 }, (_, index) => `page-${index + 1}`)) |
| 13 | |
| 14 | expect(Array.from(limitBrowsePreviewIds(ids, 20))).toEqual( |
| 15 | Array.from({ length: 20 }, (_, index) => `page-${index + 1}`) |
| 16 | ) |
| 17 | }) |
| 18 | |
| 19 | it('supports disabling browse previews', () => { |
| 20 | expect(Array.from(limitBrowsePreviewIds(new Set(['page-1']), 0))).toEqual([]) |
| 21 | }) |
| 22 | }) |
| 23 |