summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/search/results_highlighter.spec.js
blob: cfb61e9caaf0faedcb1ad2d5eb7c97cdafa16bd5 (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
describeComponent('search/results_highlighter', function () {
  'use strict';

  it('highlights words or parts of words that match with the keywords given', function () {
    this.setupComponent('<div id="text">Any one seeing too many open bugs</div>');

    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('resets highlights when a new search is performed', function() {
    this.setupComponent('<div id="text">Any one seeing too many open bugs</div>');

    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);
  });
});