(leftGap, rightGap, edges, calendar, expected)
| 1340 | |
| 1341 | describe('getBinSpanLabelRound', function() { |
| 1342 | function _test(leftGap, rightGap, edges, calendar, expected) { |
| 1343 | var ax = {type: 'not date'}; |
| 1344 | // only date axes have any different treatment here. We could explicitly |
| 1345 | // test category |
| 1346 | if(calendar) { |
| 1347 | ax = {type: 'date', calendar: 'gregorian', range: [0, 1e7]}; |
| 1348 | setConvert(ax); |
| 1349 | } |
| 1350 | |
| 1351 | var roundFn = getBinSpanLabelRound(leftGap, rightGap, edges, ax, calendar); |
| 1352 | |
| 1353 | var j = 0; |
| 1354 | var PREC = calendar ? 1 : 6; |
| 1355 | edges.forEach(function(edge, i) { |
| 1356 | if(i) { |
| 1357 | expect(roundFn(edge, true)).toBeCloseTo(expected[j], PREC, 'right ' + i); |
| 1358 | j++; |
| 1359 | } |
| 1360 | if(i < edges.length - 1) { |
| 1361 | expect(roundFn(edge)).toBeCloseTo(expected[j], PREC, 'left ' + i); |
| 1362 | j++; |
| 1363 | } |
| 1364 | }); |
| 1365 | } |
| 1366 | |
| 1367 | it('works when the bin edges are round numbers and data are "continuous"', function() { |
| 1368 | _test(0.05, 0.3, [0, 2, 4, 6], false, [0, 1.9, 2, 3.9, 4, 5.9]); |
no outgoing calls
no test coverage detected
searching dependent graphs…