Commit f1e720e5 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add specs for legend - #515

parent ea05aad7
......@@ -83,7 +83,9 @@ module.exports = (grunt) ->
c3:
src: 'c3.js'
options:
specs: 'spec/*.js'
specs: 'spec/*-spec.js'
helpers: 'spec/*-helper.js'
vendor: 'http://d3js.org/d3.v3.min.js'
uglify:
c3:
......
function initDom() {
'use strict';
var div = document.createElement('div');
div.id = 'chart';
div.style.width = '640px';
div.style.height = '480px';
document.body.appendChild(div);
document.body.style.margin = '0px';
}
typeof initDom !== 'undefined';
var describe = window.describe;
var expect = window.expect;
var it = window.it;
var c3 = window.c3;
var describe = window.describe,
expect = window.expect,
it = window.it;
describe('c3', function () {
'use strict';
it('exists', function () {
var c3 = window.c3;
expect(c3).not.toBe(null);
it('exists', function () {
expect(c3).not.toBeNull();
expect(typeof c3).toBe('object');
});
// ...write other tests here
});
var describe = window.describe,
expect = window.expect,
it = window.it,
beforeEach = window.beforeEach;
describe('c3 chart', function () {
'use strict';
var chart, d3;
beforeEach(function () {
window.initDom();
chart = window.c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', 150, 120, 110, 140, 115, 125]
]
}
});
d3 = chart.internal.d3;
});
it('should be created', function () {
var svg = d3.select('#chart svg');
expect(svg).not.toBeNull();
});
it('should have same width', function () {
var svg = d3.select('#chart svg');
expect(+svg.attr('width')).toBe(640);
});
it('should have same height', function () {
var svg = d3.select('#chart svg');
expect(+svg.attr('height')).toBe(480);
});
});
var describe = window.describe,
expect = window.expect,
it = window.it,
beforeEach = window.beforeEach;
describe('c3 chart legend', function () {
'use strict';
var chart, d3;
beforeEach(function () {
window.initDom();
chart = window.c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', 150, 120, 110, 140, 115, 125]
]
}
});
d3 = chart.internal.d3;
});
it('should be located on the center of chart', function () {
var box = chart.internal.legend.node().getBoundingClientRect();
expect(box.left + box.right).toBe(640);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment