Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

988 B
Raw Blame
import { describe, expect, it } from 'vitest';

import { splitHighlightSegments } from './highlightSegments';

describe('splitHighlightSegments', () => {
  it('marks every case-insensitive occurrence and keeps the original casing', () => {
    expect(splitHighlightSegments('Deploy, then deploy', 'DEPLOY')).toEqual([
      { match: true, text: 'Deploy' },
      { match: false, text: ', then ' },
      { match: true, text: 'deploy' },
    ]);
  });

  it('returns the text untouched for a blank keyword or no match', () => {
    expect(splitHighlightSegments('hello', '  ')).toEqual([{ match: false, text: 'hello' }]);
    expect(splitHighlightSegments('hello', 'bye')).toEqual([{ match: false, text: 'hello' }]);
  });

  it('still highlights a snippet whose lower-casing changes length', () => {
    expect(splitHighlightSegments('İstanbul deployment', 'Deployment')).toEqual([
      { match: false, text: 'İstanbul ' },
      { match: true, text: 'deployment' },
    ]);
  });
});