mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 17:14:04 +02:00
Merge branch 'kh/vitest' into develop
This commit is contained in:
@@ -74,8 +74,10 @@ export function coreFileFetcher() {
|
||||
function getUrl(url, which) {
|
||||
let prom = _inflight[url];
|
||||
if (!prom) {
|
||||
_inflight[url] = prom = fetch(url)
|
||||
_inflight[url] = prom = (window.VITEST ? import(`../${url}`) : fetch(url))
|
||||
.then(response => {
|
||||
if (window.VITEST) return response.default;
|
||||
|
||||
if (!response.ok || !response.json) {
|
||||
throw new Error(response.status + ' ' + response.statusText);
|
||||
}
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import type { FetchMockStatic } from 'fetch-mock';
|
||||
|
||||
declare global {
|
||||
declare var iD: typeof import('.');
|
||||
declare var d3: import('d3');
|
||||
declare var fetchMock: FetchMockStatic;
|
||||
declare var before: typeof beforeEach;
|
||||
declare var after: typeof afterEach;
|
||||
declare var VITEST: true;
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -23,6 +23,9 @@ export * from './validations/index';
|
||||
// This is only done in testing because of the performance penalty.
|
||||
export let debug = false;
|
||||
|
||||
/** @param {boolean} newValue */
|
||||
export const setDebug = (newValue) => { debug = newValue; };
|
||||
|
||||
// Reexport just what our tests use, see #4379
|
||||
import * as D3 from 'd3';
|
||||
export let d3 = {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IntervalTasksQueue } from '../util/IntervalTasksQueue';
|
||||
var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
|
||||
|
||||
// listen for DPI change, e.g. when dragging a browser window from a retina to non-retina screen
|
||||
window.matchMedia(`
|
||||
window.matchMedia?.(`
|
||||
(-webkit-min-device-pixel-ratio: 2), /* Safari */
|
||||
(min-resolution: 2dppx), /* standard */
|
||||
(min-resolution: 192dpi) /* fallback */
|
||||
|
||||
@@ -34,18 +34,9 @@ async function fetchAvailableLayers() {
|
||||
|
||||
const urlForRequest = owsEndpoint + utilQsString(params);
|
||||
const response = await d3_xml(urlForRequest);
|
||||
const xPathSelector = '/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType/wfs:Name';
|
||||
const regexMatcher = /^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\d{4})$/;
|
||||
const NSResolver = response.createNSResolver(response);
|
||||
const l = response.evaluate(
|
||||
xPathSelector,
|
||||
response,
|
||||
NSResolver,
|
||||
XPathResult.ANY_TYPE
|
||||
);
|
||||
let node;
|
||||
const availableLayers = [];
|
||||
while ( (node = l.iterateNext()) !== null ) {
|
||||
for (const node of response.querySelectorAll('FeatureType > Name')) {
|
||||
const match = node.textContent?.match(regexMatcher);
|
||||
if (match) {
|
||||
availableLayers.push({
|
||||
|
||||
@@ -298,7 +298,7 @@ export function uiCombobox(context, klass) {
|
||||
// https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move
|
||||
var selected = combo.selectAll('.combobox-option.selected').node();
|
||||
if (selected) {
|
||||
selected.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
selected.scrollIntoView?.({ behavior: 'smooth', block: 'nearest' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user