mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 04:31:36 +08:00
![renovate[bot]](/assets/img/avatar_default.png)
* Update jest monorepo to v29 * update snapshots + wrap test in act * fix linting errors: jest.mocked now defaults to deep mocking Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 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(`
|
|
[
|
|
"a",
|
|
"b",
|
|
"hello",
|
|
"c",
|
|
]
|
|
`);
|
|
});
|
|
|
|
it('can collect distinct values', () => {
|
|
const uniqueA = getUniqueFeatureValues(features, 'a');
|
|
const uniqueB = getUniqueFeatureValues(features, 'b');
|
|
expect(uniqueA).toMatchInlineSnapshot(`
|
|
[
|
|
"1",
|
|
"2",
|
|
]
|
|
`);
|
|
expect(uniqueB).toMatchInlineSnapshot(`
|
|
[
|
|
"10",
|
|
"20",
|
|
"30",
|
|
]
|
|
`);
|
|
});
|
|
});
|