-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathfinance_test.js
42 lines (31 loc) · 1.46 KB
/
finance_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
32
33
34
35
36
37
38
39
40
41
42
var Plots = require('@src/plots/plots');
var Plotly = require('@lib/core');
var ohlc = require('@lib/ohlc');
var candlestick = require('@lib/candlestick');
var d3Select = require('../../strict-d3').select;
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
describe('Bundle with finance trace type', function() {
'use strict';
Plotly.register([ohlc, candlestick]);
var mock = require('@mocks/finance_style.json');
it('should not register transforms anymore', function() {
var transformModules = Object.keys(Plots.transformsRegistry);
expect(transformModules).toEqual([]);
});
it('should register the correct trace modules for the generated traces', function() {
var traceModules = Object.keys(Plots.modules);
// scatter is registered no matter what
// ohlc uses some parts of box by direct require but does not need to register it.
expect(traceModules).toEqual(['scatter', 'ohlc', 'candlestick']);
});
it('should graph ohlc and candlestick traces', function(done) {
Plotly.newPlot(createGraphDiv(), mock.data, mock.layout).then(function() {
var gSubplot = d3Select('g.cartesianlayer');
expect(gSubplot.selectAll('g.trace.ohlc').size()).toEqual(1);
expect(gSubplot.selectAll('g.trace.boxes').size()).toEqual(1);
destroyGraphDiv();
done();
});
});
});