1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module( 'jquery.highlightText' );
test( '-- Initial check', function() {
expect(1);
ok( $.fn.highlightText, 'jQuery.fn.highlightText defined' );
} );
test( 'Check', function() {
var cases = [
{
text: 'Blue Öyster Cult',
highlight: 'Blue',
expected: '<span class="highlight">Blue</span> Öyster Cult'
},
{
text: 'Österreich',
highlight: 'Österreich',
expected: '<span class="highlight">Österreich</span>'
},
{
desc: 'Highlighter broken on punctuation mark',
text: 'So good. To be there',
highlight: 'good',
expected: 'So <span class="highlight">good</span>. To be there'
}
];
expect(cases.length);
var $fixture;
$.each(cases, function( i, item ) {
$fixture = $( '<p></p>' ).text( item.text );
$fixture.highlightText( item.highlight );
equals(
$fixture.html(),
$('<p>' + item.expected + '</p>').html(), // re-parse to normalize!
item.desc || undefined
);
} );
} );
|