Test for padded range when passing in values at range extremities

pull/882/head
Jared Scheib 2017-02-15 18:27:12 -08:00
parent 1bf17c9275
commit 31a599de07
1 changed files with 15 additions and 0 deletions

View File

@ -40,4 +40,19 @@ describe('getRangeForDygraphSpec', () => {
expect(actual).to.deep.equal(expected);
});
it('returns a padded range when an additional value is provided that is near or exceeds range of timeSeries data', () => {
const value0 = -10;
const value1 = 20;
const timeSeries = [[new Date(1000), value0], [new Date(2000), 1], [new Date(3000), value1]];
const unpadded = getRange(timeSeries);
const actualOne = getRange(timeSeries, undefined, value0);
const actualTwo = getRange(timeSeries, undefined, value1);
expect(actualOne[0]).to.be.below(unpadded[0]);
expect(actualOne[1]).to.equal(unpadded[1]);
expect(actualTwo[1]).to.be.above(unpadded[1]);
expect(actualTwo[0]).to.equal(unpadded[0]);
});
});