51654894c8
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
761 B
JavaScript
21 lines
761 B
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { diffLines } from './version-diff.mjs';
|
|
|
|
describe('diffLines', () => {
|
|
it('добавленные строки помечает +', () => {
|
|
const d = diffLines('a\nb', 'a\nb\nc');
|
|
expect(d).toContain('+ c');
|
|
});
|
|
it('удалённые строки помечает -', () => {
|
|
const d = diffLines('a\nb\nc', 'a\nc');
|
|
expect(d).toContain('- b');
|
|
});
|
|
it('идентичные тексты → пустой diff', () => {
|
|
expect(diffLines('a\nb', 'a\nb').trim()).toBe('');
|
|
});
|
|
it('пустой/нестроковый вход не кидает', () => {
|
|
expect(() => diffLines('', '')).not.toThrow();
|
|
expect(() => diffLines(null, undefined)).not.toThrow();
|
|
});
|
|
});
|