Browse Source

Fix axis spec

pull/654/head
Masayuki Tanaka 10 years ago
parent
commit
48f2d9bf13
  1. 30
      spec/axis-spec.js

30
spec/axis-spec.js

@ -318,14 +318,18 @@ describe('c3 chart axis', function () {
'long tick text on', 'long tick text on',
'category axis' 'category axis'
], ],
expectedX = '0', expectedX = '0';
expectedDys = ['.40em', '10', '10'];
expect(tspans.size()).toBe(3); expect(tspans.size()).toBe(3);
tspans.each(function (d, i) { tspans.each(function (d, i) {
var tspan = d3.select(this); var tspan = d3.select(this);
expect(tspan.text()).toBe(expectedTickTexts[i]); expect(tspan.text()).toBe(expectedTickTexts[i]);
expect(tspan.attr('x')).toBe(expectedX); expect(tspan.attr('x')).toBe(expectedX);
expect(tspan.attr('dy')).toBe(expectedDys[i]); // unable to define pricise number because it differs depends on environment..
if (i === 0) {
expect(tspan.attr('dy')).toBe('.40em');
} else {
expect(tspan.attr('dy')).toBeGreaterThan(8);
}
}); });
}); });
}); });
@ -362,14 +366,18 @@ describe('c3 chart axis', function () {
'long tick text', 'long tick text',
'on category axis' 'on category axis'
], ],
expectedX = '-9', expectedX = '-9';
expectedDys = ['-8', '10', '10'];
expect(tspans.size()).toBe(3); expect(tspans.size()).toBe(3);
tspans.each(function (d, i) { tspans.each(function (d, i) {
var tspan = d3.select(this); var tspan = d3.select(this);
expect(tspan.text()).toBe(expectedTickTexts[i]); expect(tspan.text()).toBe(expectedTickTexts[i]);
expect(tspan.attr('x')).toBe(expectedX); expect(tspan.attr('x')).toBe(expectedX);
expect(tspan.attr('dy')).toBe(expectedDys[i]); // unable to define pricise number because it differs depends on environment..
if (i === 0) {
expect(tspan.attr('dy')).toBeLessThan(0);
} else {
expect(tspan.attr('dy')).toBeGreaterThan(8);
}
}); });
}); });
@ -410,14 +418,18 @@ describe('c3 chart axis', function () {
'this is a very long tick text', 'this is a very long tick text',
'on category axis' 'on category axis'
], ],
expectedX = '-9', expectedX = '-9';
expectedDys = ['-3', '10'];
expect(tspans.size()).toBe(2); expect(tspans.size()).toBe(2);
tspans.each(function (d, i) { tspans.each(function (d, i) {
var tspan = d3.select(this); var tspan = d3.select(this);
expect(tspan.text()).toBe(expectedTickTexts[i]); expect(tspan.text()).toBe(expectedTickTexts[i]);
expect(tspan.attr('x')).toBe(expectedX); expect(tspan.attr('x')).toBe(expectedX);
expect(tspan.attr('dy')).toBe(expectedDys[i]); // unable to define pricise number because it differs depends on environment..
if (i === 0) {
expect(tspan.attr('dy')).toBeLessThan(0);
} else {
expect(tspan.attr('dy')).toBeGreaterThan(8);
}
}); });
}); });

Loading…
Cancel
Save