Skip to content

Commit dbdcaac

Browse files
MFedMFed
MFed
authored and
MFed
committed
fixing the unit tests for annotations and adding them back.
1 parent 91dd08a commit dbdcaac

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require('@src/plotly');
2+
var Annotations = require('@src/components/annotations');
3+
4+
describe('Test annotations', function() {
5+
'use strict';
6+
7+
describe('supplyLayoutDefaults', function() {
8+
it('should default to not use absolute arrow tail', function() {
9+
var annotationDefaults = {};
10+
annotationDefaults._has = function() { return false };
11+
12+
Annotations.supplyLayoutDefaults({ annotations: [{ showarrow: true, arrowhead: 2}] }, annotationDefaults);
13+
14+
expect(annotationDefaults.annotations[0].absolutetail).toBe(false);
15+
});
16+
17+
it('should convert ax/ay date coordinates to milliseconds if absolutetail is true', function() {
18+
var annotationOut = { xaxis: { type: 'date', range: ['2000-01-01', '2016-01-01'] }};
19+
annotationOut._has = function() { return false };
20+
21+
var annotationIn = {
22+
annotations: [{ showarrow: true, absolutetail: true, x: '2008-07-01', ax: '2004-07-01', y: 0, ay: 50}]
23+
};
24+
25+
Annotations.supplyLayoutDefaults(annotationIn, annotationOut);
26+
27+
expect(annotationIn.annotations[0].ax).toEqual(1088654400000);
28+
});
29+
});
30+
});

0 commit comments

Comments
 (0)