Skip to content

Commit 8d36189

Browse files
committed
added test cases modifying the annotations
1 parent dc5143a commit 8d36189

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/specs/annotation.spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,39 @@ describe('Annotation plugin', function() {
266266
expect(counts).toEqual([0, 1, 2, 3, 4]);
267267
});
268268

269+
it('should contain the loaded elements after reducing annotations and chart update', function() {
270+
const counts = [];
271+
const annotations = [];
272+
for (let i = 0; i < 5; i++) {
273+
annotations.push({
274+
type: 'label',
275+
content: 'test',
276+
display(context) {
277+
const check = context.chart.options.plugins.annotation.annotations.length < 5;
278+
if (check) {
279+
expect(context.elements.length).toBe(i - 2);
280+
counts.push(i);
281+
}
282+
}
283+
});
284+
}
285+
const chart = acquireChart({
286+
type: 'line',
287+
options: {
288+
plugins: {
289+
annotation: {
290+
annotations
291+
}
292+
}
293+
}
294+
});
295+
counts.splice(0, counts.length);
296+
chart.update();
297+
counts.splice(0, counts.length);
298+
chart.options.plugins.annotation.annotations = annotations.slice(2);
299+
chart.update();
300+
expect(counts).toEqual([2, 3, 4]);
301+
});
302+
269303
});
270304
});

0 commit comments

Comments
 (0)