mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-25 01:37:52 -05:00
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
/*
|
|
Tests for mapping the number of bars to the size of the svg
|
|
*/
|
|
|
|
describe('HeightScale when specifying height', function() {
|
|
var data; var bars; var HeightScale; var subject; var mockD3;
|
|
|
|
beforeEach(function() {
|
|
HeightScale = growstuff.HeightScale;
|
|
bars = [
|
|
{name: 'Shade', value: 0.2},
|
|
{name: 'Half Shade', value: 0.5},
|
|
];
|
|
data = {
|
|
bars: bars,
|
|
width: {size: 300, scale: 'linear'},
|
|
height: {size: 400, scale: 'ordinal'},
|
|
};
|
|
|
|
subject = new HeightScale(data);
|
|
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, 400], 0.05, 0);
|
|
});
|
|
});
|
|
}());
|