blob: 13131a8e9fd62b67dae643d0d6f05528197d4e6e (
plain)
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
|
describeComponent('search/results_highlighter', function () {
'use strict';
beforeEach(function () {
this.setupComponent('<div id="text">Any one seeing too many open bugs</div>');
});
it('highlights words or parts of words that match with the keywords given', function () {
this.component.attr = {keywords: ['any']};
this.component.highlightResults(event, {where: '#text'});
var highlightedWords = this.component.$node.find('.search-highlight').length;
expect(highlightedWords).toEqual(2);
});
it('highlights a string with the keywords given', function () {
this.component.attr = {keywords: ['foo']};
var expectedString = 'the <em class="search-highlight">foo</em> bar';
var string = this.component.highlightString('the foo bar');
expect(string).toEqual(expectedString);
});
it('resets highlights when a new search is performed', function() {
this.component.attr = {keywords: ['any']};
this.component.highlightResults(event, {where: '#text'});
$(document).trigger(Pixelated.events.search.resetHighlight);
var highlightedWords = this.component.$node.find('.search-highlight').length;
expect(highlightedWords).toEqual(0);
});
});
|