|
|
|
@ -14,6 +14,14 @@ describe('c3 api data', function () {
|
|
|
|
|
['data1', 30, 200, 100, 400, 150, 250], |
|
|
|
|
['data2', 5000, 2000, 1000, 4000, 1500, 2500] |
|
|
|
|
], |
|
|
|
|
names: { |
|
|
|
|
data1: 'Data Name 1', |
|
|
|
|
data2: 'Data Name 2' |
|
|
|
|
}, |
|
|
|
|
colors: { |
|
|
|
|
data1: '#FF0000', |
|
|
|
|
data2: '#00FF00' |
|
|
|
|
}, |
|
|
|
|
axes: { |
|
|
|
|
data1: 'y', |
|
|
|
|
data2: 'y2' |
|
|
|
@ -78,6 +86,56 @@ describe('c3 api data', function () {
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('data.names()', function () { |
|
|
|
|
|
|
|
|
|
it('should return data.names specified as argument', function () { |
|
|
|
|
var results = chart.data.names(); |
|
|
|
|
expect(results.data1).toBe('Data Name 1'); |
|
|
|
|
expect(results.data2).toBe('Data Name 2'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return data.names specified as api', function () { |
|
|
|
|
var results = chart.data.names({ |
|
|
|
|
data1: 'New Data Name 1', |
|
|
|
|
data2: 'New Data Name 2' |
|
|
|
|
}); |
|
|
|
|
expect(results.data1).toBe('New Data Name 1'); |
|
|
|
|
expect(results.data2).toBe('New Data Name 2'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should set data.names specified as api', function () { |
|
|
|
|
expect(d3.select('.c3-legend-item-data1 text').text()).toBe("New Data Name 1"); |
|
|
|
|
expect(d3.select('.c3-legend-item-data2 text').text()).toBe("New Data Name 2"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('data.colors()', function () { |
|
|
|
|
|
|
|
|
|
it('should return data.colors specified as argument', function () { |
|
|
|
|
var results = chart.data.colors(); |
|
|
|
|
expect(results.data1).toBe('#FF0000'); |
|
|
|
|
expect(results.data2).toBe('#00FF00'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return data.colors specified as api', function () { |
|
|
|
|
var results = chart.data.colors({ |
|
|
|
|
data1: '#00FF00', |
|
|
|
|
data2: '#FF0000' |
|
|
|
|
}); |
|
|
|
|
expect(results.data1).toBe('#00FF00'); |
|
|
|
|
expect(results.data2).toBe('#FF0000'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should set data.colors specified as api', function () { |
|
|
|
|
expect(d3.select('.c3-line-data1').style('stroke')).toBe("#00ff00"); |
|
|
|
|
expect(d3.select('.c3-line-data2').style('stroke')).toBe("#ff0000"); |
|
|
|
|
expect(d3.select('.c3-legend-item-data1 .c3-legend-item-tile').style('fill')).toBe("#00ff00"); |
|
|
|
|
expect(d3.select('.c3-legend-item-data2 .c3-legend-item-tile').style('fill')).toBe("#ff0000"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('data.axes()', function () { |
|
|
|
|
|
|
|
|
|
it('should return data.axes specified as argument', function () { |
|
|
|
|