Files
brain/tools/secretary-hookutil.test.mjs
T

31 lines
1.3 KiB
JavaScript

import { describe, it, expect } from 'vitest';
import { verifyEncoding, buildStepLinks, computePeriod, renderIndexContext } from './secretary-hookutil.mjs';
describe('verifyEncoding', () => {
it('пустое — не ок', () => { expect(verifyEncoding('').ok).toBe(false); });
it('BOM — не ок', () => { expect(verifyEncoding('текст').ok).toBe(false); });
it('нормальный UTF-8 — ок', () => { expect(verifyEncoding('текст').ok).toBe(true); });
});
describe('buildStepLinks', () => {
it('номера → метка', () => { expect(buildStepLinks([7, 12])).toBe('[→7, →12]'); });
it('пусто → пустая строка', () => { expect(buildStepLinks([])).toBe(''); });
});
describe('computePeriod', () => {
it('из флажка и текущего хода', () => {
expect(computePeriod({ startedAtTurn: 3 }, 9)).toEqual({ from: 3, to: 9 });
});
});
describe('renderIndexContext', () => {
it('оборачивает оглавление', () => {
const out = renderIndexContext('- [X](x/protocol.md) — цель · открыто · 2026-06-22');
expect(out).toContain('Открытые дела');
expect(out).toContain('x/protocol.md');
});
it('пустое — помечает отсутствие', () => {
expect(renderIndexContext('')).toContain('дел пока нет');
});
});