/* eslint-env jest */ import type { AnalysisResult } from '../../analysis/analyzer'; import { isToDo, resultTone, todoSummary } from '../result-tone'; const test = ( passed: boolean, max: number, rankMathOnly = false ): AnalysisResult => ({ id: 'keywordDensity', passed, max, score: 0, message: '', fix: '', rankMathOnly, }) as unknown as AnalysisResult; describe('the icon of a test', () => { it('is amber for a failed suggestion, red only for what counts', () => { expect(resultTone(test(false, 0))).toContain('amber'); expect(resultTone(test(false, 5))).toContain('red'); expect(resultTone(test(true, 5))).toContain('emerald'); }); it('is grey for a Rank Math test the Recomaze rules do not ask for', () => { expect(resultTone(test(false, 0, true))).toContain('muted'); expect(resultTone(test(true, 0, true))).toContain('muted'); }); }); describe('what is left to do', () => { it('is every failed test but the Rank Math comparisons', () => { expect(isToDo(test(false, 5))).toBe(true); expect(isToDo(test(false, 0))).toBe(true); expect(isToDo(test(true, 5))).toBe(false); expect(isToDo(test(false, 0, true))).toBe(false); }); }); describe('the line under the score', () => { it('counts what costs points apart from what could be better', () => { const partial = { ...test(true, 5), partial: true } as AnalysisResult; expect( todoSummary([test(false, 5), test(false, 3), partial, test(false, 0)]) ).toBe('2 to fix, 2 to improve'); expect(todoSummary([partial, test(false, 0)])).toBe('2 to improve'); expect(todoSummary([test(false, 5), test(false, 5)])).toBe('2 to fix'); }); });