1import { describe, expect, it } from 'vitest'; 2import { newerThan, parseReleases, releaseList } from './releases.mjs'; 3 4const all = parseReleases(`# Release notes 5 6## 3 — third 7- c 8 9## 2 — second 10- b 11 12## 1 — first 13- a 14`); 15const shown = (list) => list.map((r) => `${r.version}${r.open ? '+' : ''}`).join(' '); 16 17describe('releaseList', () => { 18 it('lists every release up to the page, the waiting ones open', () => { 19 expect(shown(releaseList(all, '3', newerThan(all, '1')))).toBe('3+ 2+ 1'); 20 }); 21 22 it("lists none newer than the page, and opens what it has not seen", () => { 23 expect(shown(releaseList(all, '2', [all[1]]))).toBe('2+ 1'); 24 }); 25 26 it('opens the newest when nothing else is to be opened', () => { 27 expect(shown(releaseList(all, '2', []))).toBe('2+ 1'); 28 expect(shown(releaseList(all, 'unknown', []))).toBe('3+ 2 1'); 29 expect(releaseList([], '1', [])).toEqual([]); 30 }); 31});