1 module( 'jquery.highlightText' );
3 test( '-- Initial check', function() {
5 ok( $.fn
.highlightText
, 'jQuery.fn.highlightText defined' );
8 test( 'Check', function() {
11 text
: 'Blue Öyster Cult',
13 expected
: '<span class="highlight">Blue</span> Öyster Cult'
16 text
: 'Blue Öyster Cult',
18 expected
: '<span class="highlight">Blue</span> Öyster Cult'
21 text
: 'Blue Öyster Cult',
23 expected
: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
26 text
: 'Blue Öyster Cult',
28 expected
: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
31 text
: 'Blue Öyster Cult',
33 expected
: '<span class="highlight">Blue</span> Öyster Cult'
36 text
: 'Blue Öyster Cult',
38 expected
: '<span class="highlight">Blue</span> Öyster Cult'
41 text
: 'Blue Öyster Cult',
43 expected
: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
46 text
: 'Blue Öyster Cult',
47 highlight
: ' Blue Öy',
48 expected
: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
51 desc
: 'Highlighter broken on starting Umlaut?',
53 highlight
: 'Österreich',
54 expected
: '<span class="highlight">Österreich</span>'
57 desc
: 'Highlighter broken on starting Umlaut?',
60 expected
: '<span class="highlight">Ö</span>sterreich</span>'
63 desc
: 'Highlighter broken on starting Umlaut?',
66 expected
: '<span class="highlight">Öst</span>erreich'
69 desc
: 'Highlighter broken on starting Umlaut?',
72 expected
: 'Österreich'
75 desc
: 'Highlighter broken on punctuation mark?',
76 text
: 'So good. To be there',
78 expected
: 'So <span class="highlight">good</span>. To be there'
81 desc
: 'Highlighter broken on space?',
82 text
: 'So good. To be there',
84 expected
: 'So good. To <span class="highlight">be</span> there'
87 desc
: 'Highlighter broken on space?',
88 text
: 'So good. To be there',
90 expected
: 'So good. To <span class="highlight">be</span> there'
93 desc
: 'Highlighter broken on space?',
94 text
: 'So good. To be there',
96 expected
: 'So good. To <span class="highlight">be</span> there'
99 desc
: 'Highlighter broken on space?',
100 text
: 'So good. To be there',
102 expected
: 'So good. To <span class="highlight">be</span> there'
105 desc
: 'Highlighter broken on special character at the end?',
106 text
: 'So good. xbß',
108 expected
: 'So good. <span class="highlight">xbß</span>'
111 desc
: 'Highlighter broken on special character at the end?',
112 text
: 'So good. xbß.',
114 expected
: 'So good. <span class="highlight">xbß.</span>'
117 expect(cases
.length
);
120 $.each(cases
, function( i
, item
) {
121 $fixture
= $( '<p></p>' ).text( item
.text
);
122 $fixture
.highlightText( item
.highlight
);
125 $('<p>' + item
.expected
+ '</p>').html(), // re-parse to normalize!
126 item
.desc
|| undefined