Skip to content

Commit 426ee26

Browse files
committed
Make updateFilter test more realistic
Before, it depended on pretty specific knowledge of how updateFilter is implemented, which seems quite questionable!
1 parent cf5e039 commit 426ee26

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/spec/ui/filter_spec.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,23 @@ describe('ui.filter.Filter', function () {
8686
}
8787
};
8888
annotations = [{text: 'cat'}, {text: 'dog'}, {text: 'car'}];
89+
$.each(annotations, function(i, annotation) {
90+
$('<span class="annotator-hl">')
91+
.text(annotation)
92+
.data('annotation', annotation)
93+
.appendTo(element);
94+
});
8995
plugin.filters = {'text': testFilter};
90-
plugin.highlights = {
91-
map: function () { return annotations; }
92-
};
96+
plugin.highlights = $(element).find('.annotator-hl');
9397
sandbox.stub(plugin, 'updateHighlights');
9498
sandbox.stub(plugin, 'resetHighlights');
9599
sandbox.stub(plugin, 'filterHighlights');
96100
});
97101

102+
afterEach(function () {
103+
$(element).empty();
104+
});
105+
98106
it("should call Filter#updateHighlights()", function () {
99107
plugin.updateFilter(testFilter);
100108
assert(plugin.updateHighlights.calledOnce);

0 commit comments

Comments
 (0)