mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-27 09:18:26 -04:00
added chart to the page
This commit is contained in:
1 parent
e3d2a90af8
commit
73e144278e
7 files changed
+77
-16
No files matched your search
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
|
||||
describe('GraphScale', function(){
|
||||
var GraphScale, subject;
|
||||
var data, GraphScale, subject;
|
||||
|
||||
beforeEach(function(){
|
||||
GraphScale = growstuff.GraphScale;
|
||||
@@ -10,22 +10,47 @@
|
||||
{name: 'Shade', value: 0.2},
|
||||
{name: 'Half Shade', value: 0.5}
|
||||
];
|
||||
var data = {
|
||||
data = {
|
||||
bars: bars,
|
||||
width: {size: 300, scale: 'linear'},
|
||||
height: {size: 400, scale: 'ordinal'}
|
||||
};
|
||||
|
||||
|
||||
subject = new GraphScale(data, 'width');
|
||||
subject.render(d3.select('#jasmine_content').append('svg'));
|
||||
});
|
||||
|
||||
describe('when specifying width', function() {
|
||||
var mockD3;
|
||||
beforeEach(function() {
|
||||
subject = new GraphScale(data, 'width');
|
||||
mockD3 = jasmine.createSpyObj('d3', ['domain', 'range', 'max']);
|
||||
mockD3.domain.and.returnValue(mockD3);
|
||||
mockD3.range.and.returnValue(mockD3);
|
||||
spyOn(d3.scale, 'linear').and.returnValue(mockD3);
|
||||
subject.render();
|
||||
});
|
||||
it ('gets the values of all the bars', function(){
|
||||
expect(subject.getBarValues()).toEqual([0.2, 0.5]);
|
||||
});
|
||||
|
||||
it ('calls the d3 range function to draw the width', function(){
|
||||
expect(mockD3.range).toHaveBeenCalledWith([0, 300]);
|
||||
});
|
||||
|
||||
it ('gets the values of all the bars', function(){
|
||||
expect(subject.getBarValues()).toEqual([0.2, 0.5]);
|
||||
});
|
||||
|
||||
describe('when specifying height', function() {
|
||||
var mockD3;
|
||||
beforeEach(function() {
|
||||
subject = new GraphScale(data, 'height');
|
||||
mockD3 = jasmine.createSpyObj('d3', ['domain', 'rangeRoundBands']);
|
||||
mockD3.domain.and.returnValue(mockD3);
|
||||
mockD3.rangeRoundBands.and.returnValue(mockD3);
|
||||
spyOn(d3.scale, 'ordinal').and.returnValue(mockD3);
|
||||
subject.render();
|
||||
});
|
||||
it ('calls the d3 range round bands function to draw the height', function(){
|
||||
expect(mockD3.rangeRoundBands).toHaveBeenCalledWith([0, 200], 0.05, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -61,8 +61,8 @@
|
||||
});
|
||||
|
||||
it ('on the y axis, all bars are the same height', function(){
|
||||
expect('g.bar rect:eq(0)').toHaveAttr('height', 100);
|
||||
expect('g.bar rect:eq(1)').toHaveAttr('height', 100);
|
||||
expect('g.bar rect:eq(0)').toHaveAttr('height', 195);
|
||||
expect('g.bar rect:eq(1)').toHaveAttr('height', 195);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user