Browse Source

🎉 All non-asserting specs removed. Fixes #2047. (#2050)

* 🎉 All non-asserting specs removed. Fixes #2047.

* Removing 'should update' strings

* Further text tweaks
pull/1576/merge
Ændrew Rininsland 7 years ago committed by Yoshiya Hinosawa
parent
commit
d8b82c3429
  1. 7
      spec/api.axis-spec.js
  2. 3
      spec/api.focus-spec.js
  3. 7
      spec/api.grid-spec.js
  4. 6
      spec/api.load-spec.js
  5. 11
      spec/api.region-spec.js
  6. 12
      spec/api.zoom-spec.js
  7. 30
      spec/arc-spec.js
  8. 110
      spec/axis-spec.js
  9. 32
      spec/core-spec.js
  10. 184
      spec/data-spec.js
  11. 38
      spec/domain-spec.js
  12. 45
      spec/grid-spec.js
  13. 20
      spec/interaction-spec.js
  14. 49
      spec/legend-spec.js
  15. 16
      spec/shape.bar-spec.js
  16. 31
      spec/shape.line-spec.js
  17. 3
      spec/tooltip-spec.js
  18. 30
      spec/type-spec.js

7
spec/api.axis-spec.js

@ -9,7 +9,7 @@ describe('c3 api axis', function () {
describe('axis.labels', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -31,10 +31,9 @@ describe('c3 api axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should update y axis label', function () {
it('updates y axis label', function () {
chart.axis.labels({y: 'New Y Axis Label'});
var label = d3.select('.c3-axis-y-label');
expect(label.text()).toBe('New Y Axis Label');
@ -42,7 +41,7 @@ describe('c3 api axis', function () {
expect(label.attr('dy')).toBe('1.2em');
});
it('should update y axis label', function () {
it('updates y axis label', function () {
chart.axis.labels({y2: 'New Y2 Axis Label'});
var label = d3.select('.c3-axis-y2-label');
expect(label.text()).toBe('New Y2 Axis Label');

3
spec/api.focus-spec.js

@ -378,11 +378,10 @@ describe('c3 api focus', function () {
describe('when legend.show = false', function () {
it('should update args to hide legend', function () {
beforeAll(function () {
args.legend = {
show: false
};
expect(true).toBeTruthy();
});
it('should focus all targets without showing legend', function (done) {

7
spec/api.grid-spec.js

@ -9,7 +9,7 @@ describe('c3 api grid', function () {
describe('ygrid.add and ygrid.remove', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -17,10 +17,9 @@ describe('c3 api grid', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should update y grids', function (done) {
it('updates y grids', function (done) {
var main = chart.internal.main,
expectedGrids = [
{
@ -62,7 +61,7 @@ describe('c3 api grid', function () {
}, 1200);
});
it("should update x ygrids even if it's zoomed", function (done) {
it('updates x ygrids even if zoomed', function (done) {
var main = chart.internal.main,
expectedGrids = [
{

6
spec/api.load-spec.js

@ -11,7 +11,7 @@ describe('c3 api load', function () {
describe('as column', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -20,7 +20,6 @@ describe('c3 api load', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should load additional data', function (done) {
@ -46,7 +45,7 @@ describe('c3 api load', function () {
describe('category data', function () {
it('should update arg to category data', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -62,7 +61,6 @@ describe('c3 api load', function () {
}
}
};
expect(true).toBeTruthy();
});
describe('as column', function () {

11
spec/api.region-spec.js

@ -9,7 +9,7 @@ describe('c3 api region', function () {
describe('api.region', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -31,10 +31,9 @@ describe('c3 api region', function () {
}
]
};
expect(true).toBeTruthy();
});
it('should update regions', function (done) {
it('updates regions', function (done) {
var main = chart.internal.main,
expectedRegions = [
{
@ -84,7 +83,7 @@ describe('c3 api region', function () {
describe('api.region.add', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -106,7 +105,6 @@ describe('c3 api region', function () {
}
]
};
expect(true).toBeTruthy();
});
it('should add regions', function (done) {
@ -175,7 +173,7 @@ describe('c3 api region', function () {
describe('api.region.remove', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -203,7 +201,6 @@ describe('c3 api region', function () {
},
]
};
expect(true).toBeTruthy();
});
it('should remove regions', function (done) {

12
spec/api.zoom-spec.js

@ -9,7 +9,7 @@ describe('c3 api zoom', function () {
describe('zoom', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -22,7 +22,6 @@ describe('c3 api zoom', function () {
enabled: true
}
};
expect(true).toBeTruthy();
});
it('should be zoomed properly', function () {
@ -41,7 +40,8 @@ describe('c3 api zoom', function () {
expect(domain[1]).toBe(target[1]);
});
it('should load timeseries data', function () {
describe('with timeseries data', function () {
beforeAll(function(){
args = {
data: {
x: 'date',
@ -59,7 +59,6 @@ describe('c3 api zoom', function () {
enabled: true
}
};
expect(true).toBeTruthy();
});
it('should be zoomed properly', function () {
@ -77,12 +76,12 @@ describe('c3 api zoom', function () {
expect(+domain[0]).toBe(+chart.internal.parseDate(target[0]));
expect(+domain[1]).toBe(+chart.internal.parseDate(target[1]));
});
});
});
describe('unzoom', function () {
it('should load indexed data', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -93,7 +92,6 @@ describe('c3 api zoom', function () {
enabled: true
}
};
expect(true).toBeTruthy();
});
it('should be unzoomed properly', function () {

30
spec/arc-spec.js

@ -9,7 +9,7 @@ describe('c3 chart arc', function () {
describe('show pie chart', function () {
it('should update args to have pie chart', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -20,7 +20,6 @@ describe('c3 chart arc', function () {
type: 'pie'
}
};
expect(true).toBeTruthy();
});
it('should have correct classes', function () {
@ -47,13 +46,13 @@ describe('c3 chart arc', function () {
expect(d3.select('.c3-arc-data3').attr('d')).toMatch(/M1\..+,211\..+A211\..+,211\..+ 0 0,1 -124\..+,-171\..+L0,0Z/);
});
it('should set args with data id that can be converted to a color', function () {
describe('with data id that can be converted to a color', function () {
beforeAll(function(){
args.data.columns = [
['black', 30],
['data2', 150],
['data3', 120]
];
expect(true).toBeTruthy();
});
it('should have correct d even if data id can be converted to a color', function (done) {
@ -63,7 +62,8 @@ describe('c3 chart arc', function () {
}, 500);
});
it('should update args to have empty pie chart', function () {
describe('with empty pie chart', function(){
beforeAll(function () {
args = {
data: {
columns: [
@ -74,7 +74,6 @@ describe('c3 chart arc', function () {
type: 'pie'
}
};
expect(true).toBeTruthy();
});
it('should have correct d attribute', function () {
@ -94,12 +93,14 @@ describe('c3 chart arc', function () {
expect(arcs.data2.attr('d').indexOf('NaN')).toBe(-1);
expect(arcs.data3.attr('d').indexOf('NaN')).toBe(-1);
});
});
});
});
describe('show gauge', function () {
it('should update args to have a 180 degree gauge', function () {
describe('with a 180 degree gauge', function(){
beforeAll(function () {
args = {
gauge: {
width: 10,
@ -113,7 +114,6 @@ describe('c3 chart arc', function () {
type: 'gauge'
}
};
expect(true).toBeTruthy();
});
it('should have correct d for Pi radian gauge', function () {
@ -124,8 +124,10 @@ describe('c3 chart arc', function () {
expect(data.attr('d')).toMatch(/M-304,-3\..+A304,304 0 0,1 245\..+,-178\..+L237\..+,-172\..+A294,294 0 0,0 -294,-3\..+Z/);
});
});
it('should update args to have a 2 Pi radian gauge that starts at Pi/2', function() {
describe('with a 2 Pi radian gauge that starts at Pi/2', function() {
beforeAll(function(){
args = {
gauge: {
width: 10,
@ -142,7 +144,6 @@ describe('c3 chart arc', function () {
startingAngle: Math.PI/2
}
};
expect(true).toBeTruthy();
});
it('should have correct d for 2 Pi radian gauge starting at Pi/2', function() {
@ -155,7 +156,8 @@ describe('c3 chart arc', function () {
expect(data.attr('d')).toMatch(/M-221.*?,-2\..+A221.*?,221.*? 0 1,1 -68.*?,210.*?L-65.*?,201.*?A211.*?,211.*? 0 1,0 -211.*?,-2.*?Z/);
});
it('should update labels use custom text', function() {
describe('with labels use custom text', function() {
beforeAll(function(){
args = {
gauge: {
width: 10,
@ -180,9 +182,7 @@ describe('c3 chart arc', function () {
startingAngle: Math.PI/2
}
};
expect(true).toBeTruthy();
});
it('should show custom min/max guage labels', function () {
var chartArc = d3.select('.c3-chart-arcs'),
min = chartArc.select('.c3-chart-arcs-gauge-min'),
@ -192,5 +192,7 @@ describe('c3 chart arc', function () {
expect(max.text()).toMatch('Max: 100%');
});
});
});
});
});

110
spec/axis-spec.js

@ -33,45 +33,47 @@ describe('c3 chart axis', function () {
describe('axis.y.tick.count', function () {
it('should update args to have only 1 tick on y axis', function () {
describe('with only 1 tick on y axis', function () {
beforeAll(function(){
args.axis.y.tick.count = 1;
expect(true).toBeTruthy();
});
it('should have only 1 tick on y axis', function () {
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size();
expect(ticksSize).toBe(1);
});
});
it('should update args to have 2 ticks on y axis', function () {
describe('with 2 ticks on y axis', function () {
beforeAll(function(){
args.axis.y.tick.count = 2;
expect(true).toBeTruthy();
});
it('should have 2 ticks on y axis', function () {
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size();
expect(ticksSize).toBe(2);
});
});
it('should update args to have 3 ticks on y axis', function () {
describe('with 3 ticks on y axis', function () {
beforeAll(function(){
args.axis.y.tick.count = 3;
expect(true).toBeTruthy();
});
it('should have 3 ticks on y axis', function () {
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size();
expect(ticksSize).toBe(3);
});
});
});
describe('axis.y.tick.values', function () {
var values = [100, 500];
it('should update args to have only 2 ticks on y axis', function () {
describe('with only 2 ticks on y axis', function () {
beforeAll(function(){
args.axis.y.tick.values = values;
expect(true).toBeTruthy();
});
it('should have only 2 tick on y axis', function () {
@ -85,12 +87,11 @@ describe('c3 chart axis', function () {
expect(+text).toBe(values[i]);
});
});
});
});
describe('axis y timeseries', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -107,7 +108,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have 7 ticks on y axis', function () {
@ -126,12 +126,12 @@ describe('c3 chart axis', function () {
});
});
it('should update args to set axis.y.time', function () {
describe('with axis.y.time', function () {
beforeAll(function(){
args.axis.y.tick.time = {
value : 'seconds',
interval : 60
};
expect(true).toBeTruthy();
});
it('should have 4 ticks on y axis', function () {
@ -150,6 +150,7 @@ describe('c3 chart axis', function () {
});
});
});
});
describe('axis.x.tick.values', function () {
describe('function is provided', function () {
@ -167,7 +168,7 @@ describe('c3 chart axis', function () {
}
};
chart = window.c3.generate(args);
window.generatedTicks = tickGenerator();
window.generatedTicks = tickGenerator(); // This should be removed from window
});
it('should use function to generate ticks', function () {
@ -185,7 +186,7 @@ describe('c3 chart axis', function () {
describe('not rotated', function () {
it('should update args successfully', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -202,7 +203,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should construct indexed x axis properly', function () {
@ -222,7 +222,8 @@ describe('c3 chart axis', function () {
});
});
it('should set axis.x.tick.format', function () {
describe('should set axis.x.tick.format', function () {
beforeAll(function(){
args.axis.x = {
tick: {
format: function () {
@ -230,7 +231,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should split x axis tick text to multiple lines', function () {
@ -287,13 +287,14 @@ describe('c3 chart axis', function () {
});
});
});
});
it('should set big values in y', function () {
describe('should set big values in y', function () {
beforeAll(function(){
args.data.columns = [
['data1', 3000000000000000, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25]
];
expect(true).toBeTruthy();
});
it('should not split y axis tick text to multiple lines', function () {
@ -303,14 +304,13 @@ describe('c3 chart axis', function () {
expect(tspans.size()).toBe(1);
});
});
});
});
describe('rotated', function () {
it('should update args to rotate axis', function () {
beforeAll(function () {
args.axis.rotated = true;
expect(true).toBeTruthy();
});
it('should split x axis tick text to multiple lines', function () {
@ -367,7 +367,7 @@ describe('c3 chart axis', function () {
describe('not rotated', function () {
it('should update args successfully', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -383,7 +383,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should locate ticks properly', function () {
@ -429,9 +428,8 @@ describe('c3 chart axis', function () {
describe('rotated', function () {
it('should update args to rotate axis', function () {
beforeAll(function () {
args.axis.rotated = true;
expect(true).toBeTruthy();
});
it('should locate ticks on rotated axis properly', function () {
@ -480,11 +478,10 @@ describe('c3 chart axis', function () {
describe('as null', function () {
it('should update args not to split ticks', function () {
beforeAll(function () { //'without split ticks',
args.axis.x.tick = {
multiline: false
};
expect(true).toBeTruthy();
});
it('should split x tick', function () {
@ -497,11 +494,10 @@ describe('c3 chart axis', function () {
describe('as value', function () {
it('should update args not to split ticks', function () {
beforeAll(function () { // 'without split ticks',
args.axis.x.tick = {
width: 150
};
expect(true).toBeTruthy();
});
it('should split x tick to 2 lines properly', function () {
@ -531,11 +527,10 @@ describe('c3 chart axis', function () {
describe('with axis.x.tick.format', function () {
it('should update args to use axis.x.tick.format', function () {
beforeAll(function () { // 'with axis.x.tick.format',
args.axis.x.tick.format = function () {
return ['this is a very long tick text', 'on category axis'];
};
expect(true).toBeTruthy();
});
it('should have multiline tick text', function () {
@ -556,7 +551,7 @@ describe('c3 chart axis', function () {
describe('not rotated', function () {
it('should update args successfully', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -575,7 +570,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should rotate tick texts', function () {
@ -603,7 +597,7 @@ describe('c3 chart axis', function () {
describe('not rotated', function () {
it('should update args successfully', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -620,7 +614,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should rotate tick texts', function () {
@ -646,7 +639,7 @@ describe('c3 chart axis', function () {
describe('axis.x.tick.fit = true', function () {
it('should set args for indexed data', function () {
beforeAll(function () { // 'should set args for indexed data',
args = {
data: {
columns: [
@ -656,7 +649,6 @@ describe('c3 chart axis', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should show fitted ticks on indexed data', function () {
@ -664,7 +656,8 @@ describe('c3 chart axis', function () {
expect(ticks.size()).toBe(6);
});
it('should set args for x-based data', function () {
describe('should set args for x-based data', function () {
beforeAll(function(){
args = {
data: {
x: 'x',
@ -676,7 +669,6 @@ describe('c3 chart axis', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should show fitted ticks on indexed data', function () {
@ -690,12 +682,13 @@ describe('c3 chart axis', function () {
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick');
expect(ticks.size()).toBe(6);
});
});
});
describe('axis.x.tick.fit = false', function () {
it('should set args for indexed data', function () {
describe('should set args for indexed data', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -712,15 +705,17 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should show fitted ticks on indexed data', function () {
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick');
expect(ticks.size()).toBe(11);
});
});
it('should set args for x-based data', function () {
describe('should set args for x-based data', function () {
beforeAll(function(){
args.data = {
x: 'x',
columns: [
@ -730,7 +725,6 @@ describe('c3 chart axis', function () {
['data3', 150, 120, 110, 140, 115, 125]
]
};
expect(true).toBeTruthy();
});
it('should show fitted ticks on indexed data', function () {
@ -744,13 +738,13 @@ describe('c3 chart axis', function () {
var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick');
expect(ticks.size()).toBe(10);
});
});
});
});
describe('axis.y.inner', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -764,7 +758,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should not have inner y axis', function () {
@ -776,9 +769,9 @@ describe('c3 chart axis', function () {
});
});
it('should update args to have inner y axis', function () {
describe('with inner y axis', function () {
beforeAll(function(){
args.axis.y.inner = true;
expect(true).toBeTruthy();
});
it('should have inner y axis', function () {
@ -789,12 +782,12 @@ describe('c3 chart axis', function () {
expect(+d3.select(this).attr('x')).toBeGreaterThan(0);
});
});
});
});
describe('axis.y2.inner', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -809,7 +802,6 @@ describe('c3 chart axis', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should not have inner y axis', function () {
@ -821,9 +813,9 @@ describe('c3 chart axis', function () {
});
});
it('should update args to have inner y axis', function () {
describe('with inner y axis', function () {
beforeAll(function(){
args.axis.y2.inner = true;
expect(true).toBeTruthy();
});
it('should have inner y axis', function () {
@ -834,7 +826,7 @@ describe('c3 chart axis', function () {
expect(+d3.select(this).attr('x')).toBeLessThan(0);
});
});
});
});
});

32
spec/core-spec.js

@ -27,11 +27,12 @@ describe('c3 chart', function () {
expect(svg).not.toBeNull();
});
it('should set 3rd party property to Function', function () {
describe('should set 3rd party property to Function', function () {
beforeAll(function(){
Function.prototype.$extIsFunction = true;
expect(true).toBeTruthy();
});
it('should be created even if 3rd party property has been set', function () {
var svg = d3.select('#chart svg');
expect(svg).not.toBeNull();
@ -43,6 +44,7 @@ describe('c3 chart', function () {
expect(svg.attr('class')).toBe('customclass');
});
});
});
describe('size', function () {
@ -61,11 +63,11 @@ describe('c3 chart', function () {
describe('bindto', function () {
describe('selector', function () {
it('update args', function () {
beforeAll(function(){
d3.select('#chart').html('');
args.bindto = '#chart';
expect(true).toBeTruthy();
});
it('should be created', function () {
var svg = d3.select('#chart svg');
expect(svg.size()).toBe(1);
@ -73,10 +75,9 @@ describe('c3 chart', function () {
});
describe('d3.selection object', function () {
it('update args', function () {
beforeAll(function () {
d3.select('#chart').html('');
args.bindto = d3.select('#chart');
expect(true).toBeTruthy();
});
it('should be created', function () {
var svg = d3.select('#chart svg');
@ -85,11 +86,11 @@ describe('c3 chart', function () {
});
describe('null', function () {
it('update args', function () {
beforeAll(function () {
d3.select('#chart').html('');
args.bindto = null;
expect(true).toBeTruthy();
});
it('should not be created', function () {
var svg = d3.select('#chart svg');
expect(svg.size()).toBe(0);
@ -97,22 +98,20 @@ describe('c3 chart', function () {
});
describe('empty string', function () {
it('update args', function () {
beforeAll(function () {
d3.select('#chart').html('');
args.bindto = '';
expect(true).toBeTruthy();
});
it('should not be created', function () {
var svg = d3.select('#chart svg');
expect(svg.size()).toBe(0);
});
});
});
describe('empty data', function () {
it('should upaate args for empty data', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -121,7 +120,6 @@ describe('c3 chart', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should generate a chart', function () {
@ -129,7 +127,8 @@ describe('c3 chart', function () {
expect(ticks.size()).toBe(0);
});
it('should upaate args for empty data', function () {
describe('more empty data', function () {
beforeAll(function(){
args = {
data: {
x: 'x',
@ -145,14 +144,13 @@ describe('c3 chart', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should generate a chart', function () {
var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick');
expect(ticks.size()).toBe(0);
});
});
});
});

184
spec/data-spec.js

@ -9,7 +9,7 @@ describe('c3 chart data', function () {
describe('load json', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
json: {
@ -18,7 +18,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should draw correctly', function () {
@ -31,7 +30,8 @@ describe('c3 chart data', function () {
});
});
it('should update args', function () {
describe('more data', function(){
beforeAll(function () {
args = {
data: {
json: [{
@ -57,7 +57,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should draw correctly', function () {
@ -74,8 +73,10 @@ describe('c3 chart data', function () {
expect(+circle.attr('cy')).toBeCloseTo(expectedCy[995][i], 0);
});
});
});
it('should update nested JSON args', function () {
describe('with nested JSON args', function () {
beforeAll(function(){
args = {
data: {
json: [{
@ -112,7 +113,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should draw nested JSON correctly', function () {
@ -162,11 +162,11 @@ describe('c3 chart data', function () {
expect(+circle.attr('cy')).toBeCloseTo(expectedCy[556][i], 0);
});
});
});
});
describe('function in data.order', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -179,7 +179,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should return false in isOrderAsc and isOrderDesc functions', function () {
@ -189,7 +188,7 @@ describe('c3 chart data', function () {
describe('data.xs', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -199,7 +198,6 @@ describe('c3 chart data', function () {
],
}
};
expect(true).toBeTruthy();
});
describe('normal x', function () {
@ -224,7 +222,7 @@ describe('c3 chart data', function () {
describe('timeseries x', function () {
describe('without xFormat', function () {
it('should load timeseries data successfully', function () {
beforeAll(function () {
args = {
data: {
x : 'date',
@ -240,7 +238,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have correct number of xs', function () {
@ -262,7 +259,7 @@ describe('c3 chart data', function () {
describe('with xFormat', function () {
describe('timeseries x with xFormat', function () {
it('should load timeseries data successfully', function () {
beforeAll(function () {
args = {
data: {
x : 'date',
@ -279,7 +276,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have correct number of xs', function () {
@ -304,8 +300,7 @@ describe('c3 chart data', function () {
describe('milliseconds timeseries x', function () {
describe('as date string', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
x : 'date',
@ -326,7 +321,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have correct number of xs', function () {
@ -354,7 +348,7 @@ describe('c3 chart data', function () {
describe('as unixtime number', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
x : 'date',
@ -373,7 +367,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have correct number of xs', function () {
@ -399,7 +392,7 @@ describe('c3 chart data', function () {
describe('on line chart', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -412,7 +405,6 @@ describe('c3 chart data', function () {
labels: true,
}
};
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -437,9 +429,9 @@ describe('c3 chart data', function () {
});
});
it('should update args to be stacked', function () {
describe('with stacked', function () {
beforeAll(function(){
args.data.groups = [['data1', 'data2'], ['data3', 'data4']];
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -463,12 +455,12 @@ describe('c3 chart data', function () {
});
});
});
});
});
describe('on area chart', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -481,7 +473,6 @@ describe('c3 chart data', function () {
labels: true,
}
};
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -506,9 +497,9 @@ describe('c3 chart data', function () {
});
});
it('should update args to be stacked', function () {
describe('with stacked', function () {
beforeAll(function(){
args.data.groups = [['data1', 'data2'], ['data3', 'data4']];
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -532,12 +523,13 @@ describe('c3 chart data', function () {
});
});
});
});
});
describe('on bar chart', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -550,7 +542,6 @@ describe('c3 chart data', function () {
labels: true,
}
};
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -575,9 +566,9 @@ describe('c3 chart data', function () {
});
});
it('should update args to be stacked', function () {
describe('with stacked', function () {
beforeAll(function(){
args.data.groups = [['data1', 'data2'], ['data3', 'data4']];
expect(true).toBeTruthy();
});
it('should locate data labels in correct position', function () {
@ -601,12 +592,13 @@ describe('c3 chart data', function () {
});
});
});
});
});
describe('for all targets', function () {
it('should update args to show data label for all data', function () {
describe('with data label for all data', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -617,7 +609,6 @@ describe('c3 chart data', function () {
labels: true
}
};
expect(true).toBeTruthy();
});
it('should have data labels on all data', function () {
@ -631,14 +622,15 @@ describe('c3 chart data', function () {
expect(d3.select(this).text()).toBe(args.data.columns[2][i + 1] + '');
});
});
});
});
describe('for each target', function () {
describe('as true', function () {
it('should update args to show data label for only data1', function () {
describe('with data label for only data1', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -653,7 +645,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have data labels on all data', function () {
@ -668,10 +659,12 @@ describe('c3 chart data', function () {
});
});
});
});
describe('as function', function () {
it('should update args to show data label for only data1', function () {
describe('with data label for only data1', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -686,7 +679,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have data labels on all data', function () {
@ -701,12 +693,14 @@ describe('c3 chart data', function () {
});
});
});
});
});
describe('with small values', function () {
it('should update args to show data label', function () {
describe('with data label', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -715,7 +709,6 @@ describe('c3 chart data', function () {
labels: true
}
};
expect(true).toBeTruthy();
});
it('should have proper y domain', function () {
@ -724,12 +717,13 @@ describe('c3 chart data', function () {
expect(domain[1]).toBeCloseTo(0.45);
});
});
});
describe('with positive values and null', function () {
describe('on not rotated axis', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -746,7 +740,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -766,9 +759,9 @@ describe('c3 chart data', function () {
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -787,17 +780,17 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
describe('on rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args.data.type = 'bar';
args.axis = {
rotated: true
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -816,10 +809,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -838,7 +832,7 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
});
@ -847,7 +841,8 @@ describe('c3 chart data', function () {
describe('on not rotated axis', function () {
it('should update args', function () {
describe('type bar', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -864,7 +859,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -883,10 +877,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -905,17 +900,17 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
describe('on rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args.data.type = 'bar';
args.axis = {
rotated: true
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -934,10 +929,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -956,7 +952,7 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
});
@ -965,7 +961,8 @@ describe('c3 chart data', function () {
describe('on non rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -982,7 +979,6 @@ describe('c3 chart data', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1001,10 +997,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1024,15 +1021,16 @@ describe('c3 chart data', function () {
});
});
});
});
describe('on rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args.data.type = 'bar';
args.axis = {
rotated: true
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1051,10 +1049,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1074,6 +1073,7 @@ describe('c3 chart data', function () {
});
});
});
});
});
@ -1081,7 +1081,8 @@ describe('c3 chart data', function () {
describe('on non rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -1094,7 +1095,6 @@ describe('c3 chart data', function () {
type: 'bar',
}
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1113,10 +1113,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1135,17 +1136,17 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
describe('on rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args.data.type = 'bar';
args.axis = {
rotated: true
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1164,10 +1165,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1187,6 +1189,7 @@ describe('c3 chart data', function () {
});
});
});
});
});
@ -1194,7 +1197,8 @@ describe('c3 chart data', function () {
describe('on non rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -1207,7 +1211,6 @@ describe('c3 chart data', function () {
type: 'bar',
}
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1226,10 +1229,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1248,17 +1252,17 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
});
describe('on rotated axis', function () {
it('should update args', function () {
describe('data type bar', function () {
beforeAll(function(){
args.data.type = 'bar';
args.axis = {
rotated: true
};
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1277,10 +1281,11 @@ describe('c3 chart data', function () {
expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2);
});
});
});
it('should update args', function () {
describe('data type line', function () {
beforeAll(function(){
args.data.type = 'line';
expect(true).toBeTruthy();
});
it('should have y domain with proper padding', function () {
@ -1300,6 +1305,7 @@ describe('c3 chart data', function () {
});
});
});
});
});

38
spec/domain-spec.js

@ -22,9 +22,9 @@ describe('c3 chart domain', function () {
describe('axis.y.min', function () {
it('should change axis.y.min to -100', function () {
describe('should change axis.y.min to -100', function () {
beforeAll(function(){
args.axis.y.min = -100;
expect(true).toBeTruthy();
});
it('should be set properly when smaller than max of data', function () {
@ -32,10 +32,11 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBe(-150);
expect(domain[1]).toBe(450);
});
});
it('should change axis.y.min to 500', function () {
describe('should change axis.y.min to 500', function () {
beforeAll(function(){
args.axis.y.min = 500;
expect(true).toBeTruthy();
});
it('should be set properly when bigger than max of data', function () {
@ -43,19 +44,18 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBe(499);
expect(domain[1]).toBe(511);
});
});
it('should change axis.y.min to undefined', function () {
afterAll(function(){
args.axis.y.min = undefined;
expect(true).toBeTruthy();
});
});
describe('axis.y.max', function () {
it('should change axis.y.max to 1000', function () {
describe('should change axis.y.max to 1000', function () {
beforeAll(function(){
args.axis.y.max = 1000;
expect(true).toBeTruthy();
});
it('should be set properly when bigger than min of data', function () {
@ -63,10 +63,11 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBe(-89);
expect(domain[1]).toBe(1099);
});
});
it('should change axis.y.max to 0', function () {
describe('should change axis.y.max to 0', function () {
beforeAll(function(){
args.axis.y.max = 0;
expect(true).toBeTruthy();
});
it('should be set properly when smaller than min of data', function () {
@ -74,12 +75,13 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBe(-11);
expect(domain[1]).toBe(1);
});
});
});
describe('axis.y.padding', function () {
it('should change axis.y.max to 1000', function () {
describe('should change axis.y.max to 1000', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -93,7 +95,6 @@ describe('c3 chart domain', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should be set properly when bigger than min of data', function () {
@ -101,8 +102,11 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBeCloseTo(-9, -1);
expect(domain[1]).toBeCloseTo(69, -1);
});
});
it('should change axis.y.max to 1000 with top/bottom padding', function () {
describe('should change axis.y.max to 1000 with top/bottom padding', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -119,7 +123,6 @@ describe('c3 chart domain', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should be set properly when bigger than min of data', function () {
@ -127,7 +130,6 @@ describe('c3 chart domain', function () {
expect(domain[0]).toBeCloseTo(-9, -1);
expect(domain[1]).toBeCloseTo(69, -1);
});
});
});
});

45
spec/grid-spec.js

@ -9,7 +9,7 @@ describe('c3 chart grid', function () {
describe('y grid show', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -28,16 +28,15 @@ describe('c3 chart grid', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should not show y grids', function () {
expect(chart.internal.main.select('.c3-ygrids').size()).toBe(0);
});
it('should update args to show y grids', function () {
describe('with y grids', function () {
beforeAll(function(){
args.grid.y.show = true;
expect(true).toBeTruthy();
});
it('should show y grids', function () {
@ -45,10 +44,11 @@ describe('c3 chart grid', function () {
expect(ygrids.size()).toBe(1);
expect(ygrids.selectAll('.c3-ygrid').size()).toBe(9);
});
});
it('should update args to show only 3 y grids', function () {
describe('with only 3 y grids', function () {
beforeAll(function(){
args.grid.y.ticks = 3;
expect(true).toBeTruthy();
});
it('should show only 3 y grids', function () {
@ -56,10 +56,11 @@ describe('c3 chart grid', function () {
expect(ygrids.size()).toBe(1);
expect(ygrids.selectAll('.c3-ygrid').size()).toBe(3);
});
});
it('should update args to show y grids depending on y axis ticks', function () {
describe('with y grids depending on y axis ticks', function () {
beforeAll(function(){
args.axis.y.tick.count = 5;
expect(true).toBeTruthy();
});
it('should show grids depending on y axis ticks', function () {
@ -76,12 +77,13 @@ describe('c3 chart grid', function () {
});
});
});
});
describe('y grid lines', function () {
describe('position', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -98,7 +100,6 @@ describe('c3 chart grid', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should show 3 grid lines', function () {
@ -127,7 +128,8 @@ describe('c3 chart grid', function () {
});
});
it('should update args', function () {
describe('three gridlines', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -147,7 +149,6 @@ describe('c3 chart grid', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should show 3 grid lines', function () {
@ -175,7 +176,7 @@ describe('c3 chart grid', function () {
expect(+dx).toBe(expectedDxs[i]);
});
});
});
});
});
@ -183,7 +184,7 @@ describe('c3 chart grid', function () {
describe('position', function () {
it('should have correct height', function () {
beforeAll(function () { // 'should have correct height',
args = {
data: {
columns: [
@ -200,7 +201,6 @@ describe('c3 chart grid', function () {
}
},
};
expect(true).toBeTruthy();
});
it('should show 3 grid lines', function () {
@ -229,7 +229,8 @@ describe('c3 chart grid', function () {
});
});
it('should update args', function () {
describe('three grid lines', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -249,7 +250,6 @@ describe('c3 chart grid', function () {
}
},
};
expect(true).toBeTruthy();
});
it('should show 3 grid lines', function () {
@ -277,12 +277,13 @@ describe('c3 chart grid', function () {
expect(+dx).toBe(expectedDxs[i]);
});
});
});
});
describe('with padding.top', function () {
it('should have correct height', function () {
describe('should have correct height', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -300,7 +301,6 @@ describe('c3 chart grid', function () {
top: 50
}
};
expect(true).toBeTruthy();
});
it('should show x grid lines', function () {
@ -315,12 +315,12 @@ describe('c3 chart grid', function () {
expect(t.text()).toBe(expectedText[i]);
});
});
});
});
describe('on category axis', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -343,7 +343,6 @@ describe('c3 chart grid', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should show x grid lines', function () {

20
spec/interaction-spec.js

@ -11,7 +11,7 @@ describe('c3 chart interaction', function () {
describe('custom x', function () {
it('should generate bar chart', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -22,7 +22,6 @@ describe('c3 chart interaction', function () {
type: 'bar'
}
};
expect(true).toBeTruthy();
});
it('should have 4 event rects properly', function () {
@ -35,7 +34,8 @@ describe('c3 chart interaction', function () {
});
});
it('should generate bar chart with only one data', function () {
describe('should generate bar chart with only one data', function () {
beforeAll(function(){
args = {
data: {
x: 'x',
@ -46,7 +46,6 @@ describe('c3 chart interaction', function () {
type: 'bar'
}
};
expect(true).toBeTruthy();
});
it('should have 1 event rects properly', function () {
@ -59,10 +58,10 @@ describe('c3 chart interaction', function () {
});
});
});
});
describe('timeseries', function () {
it('should generate line chart with timeseries', function () {
beforeAll(function () {
args = {
data: {
x: 'x',
@ -72,7 +71,6 @@ describe('c3 chart interaction', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should have 4 event rects properly', function () {
@ -86,7 +84,8 @@ describe('c3 chart interaction', function () {
});
it('should generate line chart with only 1 data timeseries', function () {
describe('should generate line chart with only 1 data timeseries', function () {
beforeAll(function(){
args = {
data: {
x: 'x',
@ -96,7 +95,6 @@ describe('c3 chart interaction', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should have 1 event rects properly', function () {
@ -108,9 +106,7 @@ describe('c3 chart interaction', function () {
expect(box.width).toBeCloseTo(598, -2);
});
});
});
});
});
});

49
spec/legend-spec.js

@ -9,7 +9,7 @@ describe('c3 chart legend', function () {
describe('legend when multiple charts rendered', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -19,10 +19,10 @@ describe('c3 chart legend', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should update args with long data names', function () {
describe('long data names', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -32,7 +32,6 @@ describe('c3 chart legend', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should have properly computed legend width', function () {
@ -45,10 +44,11 @@ describe('c3 chart legend', function () {
});
});
});
});
describe('legend position', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -57,7 +57,6 @@ describe('c3 chart legend', function () {
]
}
};
expect(true).toBeTruthy();
});
it('should be located on the center of chart', function () {
@ -69,7 +68,8 @@ describe('c3 chart legend', function () {
describe('legend as inset', function () {
it('should change the legend to "inset" successfully', function () {
describe('should change the legend to "inset" successfully', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -84,7 +84,6 @@ describe('c3 chart legend', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should be positioned properly', function () {
@ -97,28 +96,32 @@ describe('c3 chart legend', function () {
var box = d3.select('.c3-legend-background').node().getBoundingClientRect();
expect(box.height).toBe(48);
});
});
it('should change the legend step to 1 successfully', function () {
describe('should change the legend step to 1 successfully', function () {
beforeAll(function(){
args.legend.inset.step = 1;
expect(true).toBeTruthy();
});
it('should have automatically calculated height', function () {
var box = d3.select('.c3-legend-background').node().getBoundingClientRect();
expect(box.height).toBe(28);
});
});
it('should change the legend step to 2 successfully', function () {
describe('should change the legend step to 2 successfully', function () {
beforeAll(function(){
args.legend.inset.step = 2;
expect(true).toBeTruthy();
});
it('should have automatically calculated height', function () {
var box = d3.select('.c3-legend-background').node().getBoundingClientRect();
expect(box.height).toBe(48);
});
});
it('should update args to have only one series', function () {
describe('with only one series', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -129,7 +132,6 @@ describe('c3 chart legend', function () {
position: 'inset'
}
};
expect(true).toBeTruthy();
});
it('should locate legend properly', function () {
@ -137,12 +139,12 @@ describe('c3 chart legend', function () {
expect(box.height).toBe(28);
expect(box.width).toBeGreaterThan(64);
});
});
});
describe('legend.hide', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -154,7 +156,6 @@ describe('c3 chart legend', function () {
hide: true
}
};
expect(true).toBeTruthy();
});
it('should not show legends', function () {
@ -163,7 +164,8 @@ describe('c3 chart legend', function () {
});
});
it('should update args', function () {
describe('hidden legend', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -175,19 +177,19 @@ describe('c3 chart legend', function () {
hide: 'data2'
}
};
expect(true).toBeTruthy();
});
it('should not show legends', function () {
expect(d3.select('.c3-legend-item-data1').style('visibility')).toBe('visible');
expect(d3.select('.c3-legend-item-data2').style('visibility')).toBe('hidden');
});
});
});
describe('legend.show', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -199,7 +201,6 @@ describe('c3 chart legend', function () {
show: false
}
};
expect(true).toBeTruthy();
});
it('should not initially have rendered any legend items', function () {
@ -218,7 +219,7 @@ describe('c3 chart legend', function () {
});
describe('custom legend size', function() {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -235,7 +236,6 @@ describe('c3 chart legend', function () {
}
}
};
expect(true).toBeTruthy();
});
it('renders the legend item with the correct width and height', function () {
@ -248,7 +248,7 @@ describe('c3 chart legend', function () {
});
describe('custom legend padding', function() {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -260,7 +260,6 @@ describe('c3 chart legend', function () {
padding: 10
}
};
expect(true).toBeTruthy();
});
it('renders the correct amount of padding on the legend element', function () {

16
spec/shape.bar-spec.js

@ -12,7 +12,7 @@ describe('c3 chart shape bar', function () {
describe('with groups', function () {
describe('with indexed data', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -25,7 +25,6 @@ describe('c3 chart shape bar', function () {
type: 'bar'
},
};
expect(true).toBeTruthy();
});
it('should be stacked', function () {
var expectedBottom = [275, 293, 365, 281, 395, 290];
@ -37,7 +36,7 @@ describe('c3 chart shape bar', function () {
});
describe('with timeseries data', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
x: 'date',
@ -57,7 +56,6 @@ describe('c3 chart shape bar', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should be stacked', function () {
var expectedBottom = [275, 293, 365, 281, 395, 290];
@ -69,7 +67,7 @@ describe('c3 chart shape bar', function () {
});
describe('with category data', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
x: 'date',
@ -89,8 +87,8 @@ describe('c3 chart shape bar', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should be stacked', function () {
var expectedBottom = [275, 293, 365, 281, 395, 290];
chart.internal.main.selectAll('.c3-bars-data1 .c3-bar').each(function (d, i) {
@ -106,7 +104,7 @@ describe('c3 chart shape bar', function () {
describe('with normal axis', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -120,7 +118,6 @@ describe('c3 chart shape bar', function () {
rotated: false
}
};
expect(true).toBeTruthy();
});
it('should not be within bar', function () {
@ -151,9 +148,8 @@ describe('c3 chart shape bar', function () {
describe('with rotated axis', function () {
it('should change the chart as axis rotated', function () {
beforeAll(function () {
args.axis.rotated = true;
expect(true).toBeTruthy();
});
it('should not be within bar', function () {

31
spec/shape.line-spec.js

@ -11,7 +11,7 @@ describe('c3 chart shape line', function () {
describe('shape-rendering for line chart', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -22,8 +22,6 @@ describe('c3 chart shape line', function () {
type: 'line'
}
};
expect(true).toBeTruthy();
});
it("Should render the lines correctly", function(done) {
@ -42,9 +40,9 @@ describe('c3 chart shape line', function () {
});
});
it('should change to step chart', function () {
describe('should change to step chart', function () {
beforeAll(function(){
args.data.type = 'step';
expect(true).toBeTruthy();
});
it("should have shape-rendering = crispedges when it's step chart", function () {
@ -53,21 +51,24 @@ describe('c3 chart shape line', function () {
expect(style).toBe('crispedges');
});
});
});
it('should change to spline chart', function () {
describe('should change to spline chart', function () {
beforeAll(function(){
args.data.type = 'spline';
expect(true).toBeTruthy();
});
it('should use cardinal interpolation by default', function () {
expect(chart.internal.config.spline_interpolation_type).toBe('cardinal');
});
});
});
describe('point.show option', function () {
it('should change args to include null data', function () {
describe('should change args to include null data', function () {
beforeAll(function(){
args = {
data: {
columns: [
@ -78,7 +79,6 @@ describe('c3 chart shape line', function () {
type: 'line'
}
};
expect(true).toBeTruthy();
});
it('should not show the circle for null', function (done) {
@ -127,12 +127,13 @@ describe('c3 chart shape line', function () {
// done();
// }, 500);
// });
});
});
describe('spline.interpolation option', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -148,23 +149,21 @@ describe('c3 chart shape line', function () {
}
}
};
expect(true).toBeTruthy();
});
it('should update interpolation function', function() {
it('updates interpolation function', function() {
expect(chart.internal.getInterpolate(chart.data()[0])).toBe('monotone');
});
it('should not use a non-valid interpolation', function () {
describe('should not use a non-valid interpolation', function () {
beforeAll(function(){
args.spline.interpolation.type = 'foo';
expect(true).toBeTruthy();
});
it('should use cardinal interpolation when given option is not valid', function() {
expect(chart.internal.getInterpolate(chart.data()[0])).toBe('cardinal');
});
});
});
});

3
spec/tooltip-spec.js

@ -45,9 +45,8 @@ describe('c3 chart tooltip', function () {
describe('with left margin', function () {
it('should set left margin', function () {
beforeAll(function () {
d3.select('#chart').style('margin-left', '300px');
expect(true).toBeTruthy();
});
it('should show tooltip on proper position', function () {

30
spec/type-spec.js

@ -11,7 +11,7 @@ describe('c3 chart types', function () {
describe('with data', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -22,48 +22,48 @@ describe('c3 chart types', function () {
type: 'pie'
}
};
expect(true).toBeTruthy();
});
it('should return true', function () {
expect(chart.internal.hasArcType()).toBeTruthy();
});
it('should change chart type to "bar"', function () {
describe('should change chart type to "bar"', function () {
beforeAll(function(){
args.data.type = 'bar';
expect(true).toBeTruthy();
});
it('should return false', function () {
expect(chart.internal.hasArcType()).toBeFalsy();
});
});
});
describe('with empty data', function () {
it('should update args to have empty data', function () {
beforeAll(function () {
args = {
data: {
columns: [],
type: 'pie'
}
};
expect(true).toBeTruthy();
});
it('should return true', function () {
expect(chart.internal.hasArcType()).toBeTruthy();
});
it('should change chart type to "bar"', function () {
describe('should change chart type to "bar"', function () {
beforeAll(function(){
args.data.type = 'bar';
expect(true).toBeTruthy();
});
it('should return false', function () {
expect(chart.internal.hasArcType()).toBeFalsy();
});
});
});
@ -71,7 +71,7 @@ describe('c3 chart types', function () {
describe('internal.hasType', function () {
it('should update args', function () {
beforeAll(function () {
args = {
data: {
columns: [
@ -82,7 +82,6 @@ describe('c3 chart types', function () {
type: 'pie'
}
};
expect(true).toBeTruthy();
});
it('should return true for "pie" type', function () {
@ -97,9 +96,9 @@ describe('c3 chart types', function () {
expect(chart.internal.hasType('bar')).toBeFalsy();
});
it('should unload successfully', function () {
describe('should unload successfully', function () {
beforeAll(function(){
chart.unload([]);
expect(true).toBeTruthy();
});
it('should return true for "pie" type even if no data', function () {
@ -114,9 +113,9 @@ describe('c3 chart types', function () {
expect(chart.internal.hasType('bar')).toBeFalsy();
});
it('should change chart type to "bar" successfully', function () {
describe('should change chart type to "bar" successfully', function () {
beforeAll(function(){
args.data.type = 'bar';
expect(true).toBeTruthy();
});
it('should return false for "pie" type even if no data', function () {
@ -130,7 +129,8 @@ describe('c3 chart types', function () {
it('should return true for "bar" type even if no data', function () {
expect(chart.internal.hasType('bar')).toBeTruthy();
});
});
});
});

Loading…
Cancel
Save