summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/search/results_highlighter.spec.js
blob: 523c3599ac39e8a69d4db6a40c90dcb2eef9bb84 (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 only words that matches 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(1);
  });

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