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
|
module('chart_title');
test('Chart title is updated', function() {
var params = {
title: 'foo',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}]
};
var params2 = MG.clone(params);
params2.title = 'bar';
MG.data_graphic(params);
MG.data_graphic(params2);
equal(document.querySelector('.mg-chart-title').textContent, 'bar', 'Chart title is foo');
});
test('Chart title is removed if title is set to blank', function() {
var params = {
title: 'foo',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}]
};
var params2 = MG.clone(params);
params2.title = '';
MG.data_graphic(params);
MG.data_graphic(params2);
equal(document.querySelector('.mg-chart-title'), null, 'Chart title is not added');
});
test('Chart title is removed if title is not set', function() {
var params = {
title: 'foo',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}]
};
var params2 = MG.clone(params);
delete params2.title;
MG.data_graphic(params);
MG.data_graphic(params2);
equal(document.querySelector('.mg-chart-title'), null, 'Chart title is not added');
});
test('When a description is set, we get a question mark', function() {
var params = {
title: 'foo',
description: 'bar',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
show_tooltips: true
};
MG.data_graphic(params);
ok(document.querySelector('.mg-chart-description'), 'Description icon exists');
});
test('When an error is set, we get an exclamation icon', function() {
var params = {
title: 'foo',
description: 'bar',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}],
error: 'lorem ipsum'
};
MG.data_graphic(params);
ok(document.querySelector('.mg-chart-title .mg-warning'), 'Error icon exists');
});
test('Chart title is not duplicated on redraw', function() {
var params = {
title: 'foo',
target: '#qunit-fixture',
data: [{'date': new Date('2014-01-01'), 'value': 12},
{'date': new Date('2014-03-01'), 'value': 18}]
};
var params2 = MG.clone(params);
MG.data_graphic(params);
MG.data_graphic(params2);
equal(document.querySelectorAll('.mg-chart-title').length, 1, 'there is once chart title');
});
|