/
githubmirror
/
30-seconds-of-code
Обзор
Документация
Войти
/
githubmirror
/
30-seconds-of-code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
spec/lib/contentUtils/tocReader.test.js
26 строк
800 B
Angelos Chalaris
Fix broken test
28 мар 2025, 20:18
Не верифицирован
28 мар 2025, 20:18
d458ab1
Код
Авторство
О чём код?
import { describe, it, expect } from 'vitest'; import TocReader from '#src/lib/contentUtils/tocReader.js'; describe('TocReader.readToC', () => { it('should read and build a table of contents from HTML', () => { const html = ` <h2><a id="foo" href="#foo">Foo</a></h2> <h3><a id="bar" href="#bar">Bar</a></h3> <h4><a id="baz" href="#baz">Baz</a></h4> `; const toc = TocReader.readToC(html); expect(toc).toBe( '<table-of-contents><ol><li><a href="#foo">Foo</a><ol><li><a href="#bar">Bar</a><ol><li><a href="#baz">Baz</a></li></ol></li></ol></li></ol></table-of-contents>' ); }); it('should return undefined if no headings are found', () => { const html = ''; const toc = TocReader.readToC(html); expect(toc).toBe(undefined); }); });