Files
grafana/public/app/plugins/panel/geomap/utils/getFeatures.test.ts
Josh Hunt 3c6e0e8ef8 Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

46 lines
1.2 KiB
TypeScript

import { Feature } from 'ol';
import { Point } from 'ol/geom';
import { GeometryTypeId } from '../style/types';
import { getLayerPropertyInfo, getUniqueFeatureValues } from './getFeatures';
describe('get features utils', () => {
const features = [
new Feature({ a: 1, b: 30, hello: 'world', geometry: new Point([0, 0]) }),
new Feature({ a: 2, b: 20, hello: 'world', geometry: new Point([0, 0]) }),
new Feature({ a: 2, b: 10, c: 30, geometry: new Point([0, 0]) }),
];
it('reads the distinct field names', () => {
const info = getLayerPropertyInfo(features);
expect(info.geometryType).toBe(GeometryTypeId.Point);
expect(info.propertes.map((v) => v.value)).toMatchInlineSnapshot(`
Array [
"a",
"b",
"hello",
"c",
]
`);
});
it('can collect distinct values', () => {
const uniqueA = getUniqueFeatureValues(features, 'a');
const uniqueB = getUniqueFeatureValues(features, 'b');
expect(uniqueA).toMatchInlineSnapshot(`
Array [
"1",
"2",
]
`);
expect(uniqueB).toMatchInlineSnapshot(`
Array [
"10",
"20",
"30",
]
`);
});
});