Skip to content

Commit

Permalink
Adding some test coverage for /lib/client/renderer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-fredregill committed Oct 15, 2017
1 parent 1c387b8 commit 68af094
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/

bundle/bundle.out.js

.vscode/
.idea/
*.iml
my.env
Expand All @@ -22,4 +23,4 @@ coverage/
npm-debug.log
*.heapsnapshot

/tmp
/tmp
29 changes: 29 additions & 0 deletions tests/client.renderer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

require('should');
let _ = require('lodash');

let renderer = require('../lib/client/renderer');
const MAX_DELTA = 0.0001;
const PREV_CHART_WIDTHS = [
{ width: 400, expectedScale: 3.5 }
, { width: 500, expectedScale: 2.625 }
, { width: 900, expectedScale: 1.75 }
];

describe('renderer', () => {
describe('bubbleScale', () => {
_.forEach(PREV_CHART_WIDTHS, (prev) => {
describe(`prevChartWidth < ${prev.width}`, () => {
let mockClient = {
utils: true
, chart: { prevChartWidth: prev.width }
, foucusRangeMS: true
};
it('scales correctly', () => {
renderer(mockClient, {}).bubbleScale().should.be.approximately(prev.expectedScale, MAX_DELTA);
});
});
});
});
});

0 comments on commit 68af094

Please sign in to comment.