mirror of
https://github.com/grafana/grafana.git
synced 2025-09-24 19:23:51 +08:00

* 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
46 lines
1.2 KiB
TypeScript
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",
|
|
]
|
|
`);
|
|
});
|
|
});
|