worldmap.test.ts 979 B

12345678910111213141516171819202122232425262728293031323334
  1. import { toLonLat } from 'ol/proj';
  2. import countriesJSON from '../../../../gazetteer/countries.json';
  3. import { getGazetteer } from './gazetteer';
  4. let backendResults: any = { hello: 'world' };
  5. jest.mock('@grafana/runtime', () => ({
  6. ...(jest.requireActual('@grafana/runtime') as unknown as object),
  7. getBackendSrv: () => ({
  8. get: jest.fn().mockResolvedValue(backendResults),
  9. }),
  10. }));
  11. describe('Placename lookup from worldmap format', () => {
  12. beforeEach(() => {
  13. backendResults = { hello: 'world' };
  14. });
  15. it('unified worldmap config', async () => {
  16. backendResults = countriesJSON;
  17. const gaz = await getGazetteer('countries');
  18. expect(gaz.error).toBeUndefined();
  19. expect(toLonLat(gaz.find('US')?.point()?.getCoordinates()!)).toMatchInlineSnapshot(`
  20. Array [
  21. -95.712891,
  22. 37.09023999999998,
  23. ]
  24. `);
  25. // Items with 'keys' should get allow looking them up
  26. expect(gaz.find('US')).toEqual(gaz.find('USA'));
  27. });
  28. });