QUnit.module( 'jquery.highlightText', () => { QUnit.test.each( 'highlightText()', [ { text: 'Blue Öyster Cult', highlight: 'Blue', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: 'Blue ', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: 'Blue Ö', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: 'Blue Öy', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: ' Blue', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: ' Blue ', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: ' Blue Ö', expected: 'Blue Öyster Cult' }, { text: 'Blue Öyster Cult', highlight: ' Blue Öy', expected: 'Blue Öyster Cult' }, // Highlighter on starting Umlaut { text: 'Österreich', highlight: 'Österreich', expected: 'Österreich' }, { text: 'Österreich', highlight: 'Ö', expected: 'Österreich' }, { text: 'Österreich', highlight: 'Öst', expected: 'Österreich' }, { text: 'Österreich', highlight: 'Oe', expected: 'Österreich' }, { text: 'So good. To be there', highlight: 'good', expected: 'So good. To be there' }, // Highlighter on space { text: 'So good. To be there', highlight: 'be', expected: 'So good. To be there' }, { text: 'So good. To be there', highlight: ' be', expected: 'So good. To be there' }, { text: 'So good. To be there', highlight: 'be ', expected: 'So good. To be there' }, { text: 'So good. To be there', highlight: ' be ', expected: 'So good. To be there' }, // Highlighter with special character at the end { text: 'So good. xbß', highlight: 'xbß', expected: 'So good. xbß' }, { text: 'So good. xbß.', highlight: 'xbß.', expected: 'So good. xbß.' }, { text: 'חסיד אומות העולם', highlight: 'חסיד אומות העולם', expected: 'חסיד אומות העולם' }, { text: 'חסיד אומות העולם', highlight: 'חסי', expected: 'חסיד אומות העולם' }, // Japanese (ja) { text: '諸国民の中の正義の人', highlight: '諸国民の中の正義の人', expected: '諸国民の中の正義の人' }, { text: '諸国民の中の正義の人', highlight: '諸国', expected: '諸国民の中の正義の人' }, // French (fr) text and french guillemets quotes { text: '« L\'oiseau est sur l’île »', highlight: '« L\'oiseau est sur l’île »', expected: '« L\'oiseau est sur l’île »' }, { text: '« L\'oiseau est sur l’île »', highlight: '« L\'oise', expected: '« L\'oiseau est sur l’île »' }, { // does it match the single strings "«" and "L" separately? text: '« L\'oiseau est sur l’île »', highlight: '« L', expected: '« L\'oiseau est sur l’île »' }, // Russian (ru) { text: 'Праведники мира', highlight: 'Праведники мира', expected: 'Праведники мира' }, { text: 'Праведники мира', highlight: 'Праве', expected: 'Праведники мира' }, // Georgian (ka) { text: 'მთავარი გვერდი', highlight: 'მთავარი გვერდი', expected: 'მთავარი გვერდი' }, { text: 'მთავარი გვერდი', highlight: 'მთა', expected: 'მთავარი გვერდი' }, // Armenian (hy) { text: 'Նոնա Գափրինդաշվիլի', highlight: 'Նոնա Գափրինդաշվիլի', expected: 'Նոնա Գափրինդաշվիլի' }, { text: 'Նոնա Գափրինդաշվիլի', highlight: 'Նոն', expected: 'Նոնա Գափրինդաշվիլի' }, // Thai (th) { text: 'พอล แอร์ดิช', highlight: 'พอล แอร์ดิช', expected: 'พอล แอร์ดิช' }, { text: 'พอล แอร์ดิช', highlight: 'พอ', expected: 'พอล แอร์ดิช' }, // RTL: Arabic (ar) { text: 'بول إيردوس', highlight: 'بول إيردوس', expected: 'بول إيردوس' }, { text: 'بول إيردوس', highlight: 'بو', expected: 'بول إيردوس' } ], ( assert, item ) => { const $fixture = $( '
' ).text( item.text ).highlightText( item.highlight ); assert.strictEqual( $fixture.html(), // Re-parse to normalize $( '
' ).html( item.expected ).html() ); } ); } );