mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-05 16:34:57 +05:30
chore: set text in english not the best langage, french
This commit is contained in:
parent
9ef1ac2833
commit
170bdfad8a
1 changed files with 21 additions and 25 deletions
|
|
@ -3,40 +3,40 @@ import { compareTextsHtml } from './service';
|
|||
|
||||
describe('compareTextsHtml', () => {
|
||||
it('should highlight added text', () => {
|
||||
const textA = 'Bonjour tout le monde';
|
||||
const textB = 'Bonjour tout le monde ici';
|
||||
const textA = 'Hello world';
|
||||
const textB = 'Hello world here';
|
||||
|
||||
const result = compareTextsHtml(textA, textB);
|
||||
expect(result).toContain('<span class="diff-added"> ici</span>');
|
||||
expect(result).toContain('<span class="diff-added"> here</span>');
|
||||
});
|
||||
|
||||
it('should highlight removed text', () => {
|
||||
const textA = 'Bonjour tout le monde ici';
|
||||
const textB = 'Bonjour tout le monde';
|
||||
const textA = 'Hello world here';
|
||||
const textB = 'Hello world';
|
||||
|
||||
const result = compareTextsHtml(textA, textB);
|
||||
expect(result).toContain('<span class="diff-removed"> ici</span>');
|
||||
expect(result).toContain('<span class="diff-removed"> here</span>');
|
||||
});
|
||||
|
||||
it('should highlight changes in the middle of a sentence', () => {
|
||||
const textA = 'Je suis à Lyon';
|
||||
const textB = 'Je suis à Marseille';
|
||||
const textA = 'I am in Lyon';
|
||||
const textB = 'I am in Marseille';
|
||||
|
||||
const result = compareTextsHtml(textA, textB);
|
||||
expect(result).toContain('Je suis à ');
|
||||
expect(result).toContain('I am in ');
|
||||
expect(result).toContain('<span class="diff-removed">Lyon</span>');
|
||||
expect(result).toContain('<span class="diff-added">Marseille</span>');
|
||||
});
|
||||
|
||||
it('should return empty diff if texts are identical', () => {
|
||||
const input = 'Même texte partout';
|
||||
it('should return plain diff if texts are identical', () => {
|
||||
const input = 'Same text everywhere';
|
||||
const result = compareTextsHtml(input, input);
|
||||
expect(result).toContain('<span>Même texte partout</span>');
|
||||
expect(result).toContain('<span>Same text everywhere</span>');
|
||||
expect(result).not.toContain('diff-added');
|
||||
expect(result).not.toContain('diff-removed');
|
||||
});
|
||||
|
||||
it('should handle HTML escaping', () => {
|
||||
it('should escape HTML characters', () => {
|
||||
const textA = '<b>Hello</b>';
|
||||
const textB = '<b>Hello world</b>';
|
||||
|
||||
|
|
@ -45,28 +45,24 @@ describe('compareTextsHtml', () => {
|
|||
expect(result).toContain('<span class="diff-added"> world</span>');
|
||||
});
|
||||
|
||||
it('should return a single div with class diff-line', () => {
|
||||
it('should wrap result in a single diff-line div', () => {
|
||||
const result = compareTextsHtml('foo', 'bar');
|
||||
expect(result.startsWith('<div class="diff-line">')).toBe(true);
|
||||
expect(result.endsWith('</div>')).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle empty strings', () => {
|
||||
it('should handle empty input strings', () => {
|
||||
const result = compareTextsHtml('', '');
|
||||
expect(result).toBe('<div class="diff-line"></div>');
|
||||
});
|
||||
|
||||
it('should handle only added content', () => {
|
||||
const result = compareTextsHtml('', 'Nouveau texte');
|
||||
expect(result).toContain(
|
||||
'<span class="diff-added">Nouveau texte</span>'
|
||||
);
|
||||
it('should handle only added input', () => {
|
||||
const result = compareTextsHtml('', 'New text');
|
||||
expect(result).toContain('<span class="diff-added">New text</span>');
|
||||
});
|
||||
|
||||
it('should handle only removed content', () => {
|
||||
const result = compareTextsHtml('Ancien texte', '');
|
||||
expect(result).toContain(
|
||||
'<span class="diff-removed">Ancien texte</span>'
|
||||
);
|
||||
it('should handle only removed input', () => {
|
||||
const result = compareTextsHtml('Old text', '');
|
||||
expect(result).toContain('<span class="diff-removed">Old text</span>');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue