-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathannotations_test.js
31 lines (23 loc) · 1.23 KB
/
annotations_test.js
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
27
28
29
30
31
require('@src/plotly');
var Annotations = require('@src/components/annotations');
var Dates = require('@src/lib/dates');
describe('Test annotations', function() {
'use strict';
describe('supplyLayoutDefaults', function() {
it('should default to not use absolute arrow tail', function() {
var annotationDefaults = {};
annotationDefaults._has = function() { return false; };
Annotations.supplyLayoutDefaults({ annotations: [{ showarrow: true, arrowhead: 2}] }, annotationDefaults);
expect(annotationDefaults.annotations[0].absolutetail).toBe(false);
});
it('should convert ax/ay date coordinates to milliseconds if absolutetail is true', function() {
var annotationOut = { xaxis: { type: 'date', range: ['2000-01-01', '2016-01-01'] }};
annotationOut._has = function() { return false; };
var annotationIn = {
annotations: [{ showarrow: true, absolutetail: true, x: '2008-07-01', ax: '2004-07-01', y: 0, ay: 50}]
};
Annotations.supplyLayoutDefaults(annotationIn, annotationOut);
expect(annotationIn.annotations[0].ax).toEqual(Dates.dateTime2ms('2004-07-01'));
});
});
});