fix: Handle rendering a single point (#7256)

* fix: Handle rendering a single point

* fix: typo
This commit is contained in:
Kim Truong
2019-04-09 15:46:47 -07:00
committed by Beto Dealmeida
parent 7c80cf58eb
commit 2a67e8e457
2 changed files with 102 additions and 3 deletions

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import { max } from 'd3-array';
import { getAggFunc } from '../../../../../src/visualizations/deckgl/layers/common';
import { getAggFunc, getBounds } from '../../../../../src/visualizations/deckgl/layers/common';
describe('deckgl layers common', () => {
it('getAggFunc', () => {
@@ -46,4 +46,65 @@ describe('deckgl layers common', () => {
expect(getAggFunc('p95', accessor)(arr)).toEqual(2.9);
expect(getAggFunc('p99', accessor)(arr)).toEqual(2.98);
});
describe('getBounds', () => {
it('should return valid bounds for multiple points', () => {
const points = [
[0, 20],
[5, 25],
[10, 15],
];
expect(getBounds(points)).toEqual([
[0, 15],
[10, 25],
]);
});
it('should return valid bounds for single latitude point', () => {
const points = [
[0, 0],
[5, 0],
];
expect(getBounds(points)).toEqual([
[0, -0.25],
[5, 0.25],
]);
});
it('should return valid bounds for single longitude point', () => {
const points = [
[0, 0],
[0, 5],
];
expect(getBounds(points)).toEqual([
[-0.25, 0],
[0.25, 5],
]);
});
it('should return valid bounds for single point', () => {
const points = [
[0, 0],
];
expect(getBounds(points)).toEqual([
[-0.25, -0.25],
[0.25, 0.25],
]);
});
it('should return valid bounds for point 90, 180', () => {
const points = [
[180, 90],
];
expect(getBounds(points)).toEqual([
[179.75, 89.75],
[180, 90],
]);
});
it('should return valid bounds for point -90, -180', () => {
const points = [
[-180, -90],
];
expect(getBounds(points)).toEqual([
[-180, -90],
[-179.75, -89.75],
]);
});
});
});