45 lines
2.2 KiB
JavaScript
45 lines
2.2 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { formatJudgeObjection, formatMentorObjection } from './objection-format.mjs';
|
|
|
|
describe('formatJudgeObjection', () => {
|
|
it('склеивает дословные возражения (anchor.ref + severity)', () => {
|
|
const v = { objections: [
|
|
{ verdict: 'NO', anchor: { kind: 'failed_criterion', ref: 'шаг 3 не проверяемый исход' }, severity: 'heavy' },
|
|
], slots: {} };
|
|
const s = formatJudgeObjection(v);
|
|
expect(s).toContain('шаг 3 не проверяемый исход');
|
|
expect(s).toContain('heavy');
|
|
});
|
|
it('несколько возражений — все в выводе', () => {
|
|
const v = { objections: [{ anchor: { ref: 'A' }, severity: 'fatal' }, { anchor: { ref: 'B' }, severity: 'light' }] };
|
|
const s = formatJudgeObjection(v);
|
|
expect(s).toContain('A');
|
|
expect(s).toContain('B');
|
|
});
|
|
it('нет возражений → пустая строка', () => {
|
|
expect(formatJudgeObjection({ objections: [], slots: {} })).toBe('');
|
|
});
|
|
it('мусорный вердикт не роняет', () => {
|
|
expect(formatJudgeObjection(null)).toBe('');
|
|
expect(formatJudgeObjection({ objections: 'x' })).toBe('');
|
|
});
|
|
it('возражение без anchor.ref пропускается', () => {
|
|
expect(formatJudgeObjection({ objections: [{ severity: 'heavy' }] })).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('formatMentorObjection', () => {
|
|
it('собирает дословный reason + замечания вердикта', () => {
|
|
const s = formatMentorObjection({ ok: false, wired: true, reason: 'шаг 2 склеен', verdict: { objections: [{ anchor: { ref: 'разбей шаг 2' } }] } });
|
|
expect(s).toContain('шаг 2 склеен');
|
|
expect(s).toContain('разбей шаг 2');
|
|
});
|
|
it('ok=true → пустая строка (нет замечания)', () => {
|
|
expect(formatMentorObjection({ ok: true, wired: true })).toBe('');
|
|
});
|
|
it('не wired → пустая строка ($0, наставник не судил)', () => {
|
|
expect(formatMentorObjection({ ok: false, wired: false })).toBe('');
|
|
});
|
|
it('мусор не роняет', () => { expect(formatMentorObjection(null)).toBe(''); });
|
|
});
|