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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
module('point');
// this test doesn't work properly.
// test('A solitary active datapoint exists', function() {
// var params = {
// target: '#qunit-fixture',
// data: [{'date': new Date('2014-01-01'), 'value': 12},
// {'date': new Date('2014-03-01'), 'value': 18}],
// chart_type: 'point'
// };
// MG.data_graphic(params);
// equal(document.querySelectorAll('.mg-active-datapoint').length, 1, 'One active datapoint exists');
// });
test('Rollovers exist', function() {
var params = {
target: '#qunit-fixture',
data: [[{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
[{'date': new Date('2014-01-01'), 'value': 120},
{'date': new Date('2014-03-01'), 'value': 180}]],
chart_type: 'point'
};
MG.data_graphic(params);
ok(document.querySelector('.mg-voronoi'), 'Rollovers exist');
});
test('We have only one set of rollovers', function() {
var params = {
target: '#qunit-fixture',
data: [[{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
[{'date': new Date('2014-01-01'), 'value': 120},
{'date': new Date('2014-03-01'), 'value': 180}]],
chart_type: 'point'
};
MG.data_graphic(params);
equal(document.querySelectorAll('.mg-voronoi').length, 1, 'One set of rollovers exists');
});
test('args.x_rug', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
x_rug: true,
chart_type: 'point'
};
MG.data_graphic(params);
ok(document.querySelector('.mg-x-rug'), 'X-axis rugplot exists');
});
test('Only one rugplot is added on multiple calls to the same target element', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
x_rug: true,
chart_type: 'point'
};
MG.data_graphic(params);
MG.data_graphic(MG.clone(params));
equal(document.querySelectorAll('.mg-x-rug').length, 2, 'We only have one rugplot (two ticks) on the x-axis');
});
test('args.y_rug', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
y_rug: true,
chart_type: 'point'
};
MG.data_graphic(params);
ok(document.querySelector('.mg-y-rug'), 'Y-axis rugplot exists');
});
test('Only one rugplot is added on multiple calls to the same target element', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
y_rug: true,
chart_type: 'point'
};
MG.data_graphic(params);
MG.data_graphic(MG.clone(params));
equal(document.querySelectorAll('.mg-y-rug').length, 2, 'We only have one rugplot (two ticks) on the y-axis');
});
test('args.least_squares', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
chart_type: 'point',
least_squares: true
};
MG.data_graphic(params);
ok(document.querySelector('.mg-least-squares-line'), 'Least-squares line exists');
});
test('Only one least-squares line is added on multiple calls to the same target element', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
chart_type: 'point',
least_squares: true
};
MG.data_graphic(params);
MG.data_graphic(MG.clone(params));
equal(document.querySelectorAll('.mg-least-squares-line').length, 1, 'We only have one least-squares line');
});
test('Only one active data point container added on multiple calls to the same target element (points)', function() {
var params = {
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
chart_type: 'point'
};
MG.data_graphic(params);
MG.data_graphic(MG.clone(params));
equal(document.querySelectorAll('.mg-active-datapoint-container').length, 1, 'We only have one mg-active-datapoint-container with points');
});
|