mirror of https://github.com/masayuki0812/c3.git
5 changed files with 95 additions and 13 deletions
@ -0,0 +1,11 @@
|
||||
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'; |
@ -1,20 +1,15 @@
|
||||
|
||||
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
|
||||
|
||||
}); |
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
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); |
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,32 @@
|
||||
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); |
||||
}); |
||||
|
||||
}); |
Loading…
Reference in new issue