forked from dc-js/dc.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-count-test.js
60 lines (53 loc) · 1.74 KB
/
data-count-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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require("./env");
var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('Data count widget');
function buildChart(id) {
var div = d3.select("body").append("div").attr("id", id);
div.append("span").attr("class", "filter-count");
div.append("span").attr("class", "total-count");
countryDimension.filter("CA");
var chart = dc.dataCount("#" + id)
.transitionDuration(0)
.dimension(data)
.group(groupAll);
chart.render();
return chart;
}
suite.addBatch({
'creation': {
topic: function() {
return buildChart("data-count");
},
'should generate something': function(chart) {
assert.isNotNull(chart);
},
'should be registered':function(chart) {
assert.isTrue(dc.hasChart(chart));
},
'should fill in the total count': function(chart) {
assert.equal(chart.select("span.total-count").text(), "10");
},
'should fill in the total count': function(chart) {
assert.equal(chart.select("span.filter-count").text(), "2");
},
'redraw':{
topic: function(chart) {
resetAllFilters();
chart.redraw();
return chart;
},
'should fill in the updated total count': function(chart) {
assert.equal(chart.select("span.total-count").text(), "10");
},
'should fill in the updated total count': function(chart) {
assert.equal(chart.select("span.filter-count").text(), "10");
}
},
'teardown': function() {
resetAllFilters();
resetBody();
}
}
});
suite.export(module);