Skip to content

Commit 3ebfb0b

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 bc1b3c7 commit 3ebfb0b

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
@@ -124,15 +124,23 @@ describe('ui.filter.Filter', function () {
124124
}
125125
};
126126
annotations = [{text: 'cat'}, {text: 'dog'}, {text: 'car'}];
127+
$.each(annotations, function(i, annotation) {
128+
$('<span class="annotator-hl">')
129+
.text(annotation)
130+
.data('annotation', annotation)
131+
.appendTo(element);
132+
});
127133
plugin.filters = {'text': testFilter};
128-
plugin.highlights = {
129-
map: function () { return annotations; }
130-
};
134+
plugin.highlights = $(element).find('.annotator-hl');
131135
sandbox.stub(plugin, 'updateHighlights');
132136
sandbox.stub(plugin, 'resetHighlights');
133137
sandbox.stub(plugin, 'filterHighlights');
134138
});
135139

140+
afterEach(function () {
141+
$(element).empty();
142+
});
143+
136144
it("should call Filter#updateHighlights()", function () {
137145
plugin.updateFilter(testFilter);
138146
assert(plugin.updateHighlights.calledOnce);

0 commit comments

Comments
 (0)