mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 13:11:41 +02:00
Fix code tests for #8276 for real this time
Add utilFetchJson to get around some quirks of d3.json and use it for coreFileFetcher Load real general English locale strings at the beginning of code tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { json as d3_json } from 'd3-fetch';
|
||||
import { utilFetchJson } from '../util/util';
|
||||
|
||||
let _mainFileFetcher = coreFileFetcher(); // singleton
|
||||
|
||||
@@ -54,7 +54,7 @@ export function coreFileFetcher() {
|
||||
|
||||
let prom = _inflight[url];
|
||||
if (!prom) {
|
||||
_inflight[url] = prom = d3_json(url)
|
||||
_inflight[url] = prom = utilFetchJson(url)
|
||||
.then(result => {
|
||||
delete _inflight[url];
|
||||
if (!result) {
|
||||
|
||||
@@ -26,6 +26,7 @@ export { utilEntitySelector } from './util';
|
||||
export { utilEntityOrMemberSelector } from './util';
|
||||
export { utilEntityOrDeepMemberSelector } from './util';
|
||||
export { utilFastMouse } from './util';
|
||||
export { utilFetchJson } from './util';
|
||||
export { utilFunctor } from './util';
|
||||
export { utilGetAllNodes } from './util';
|
||||
export { utilGetSetValue } from './get_set_value';
|
||||
|
||||
@@ -572,3 +572,14 @@ export function utilUnicodeCharsCount(str) {
|
||||
export function utilUnicodeCharsTruncated(str, limit) {
|
||||
return Array.from(str).slice(0, limit).join('');
|
||||
}
|
||||
|
||||
// Variation of d3.json (https://github.com/d3/d3-fetch/blob/master/src/json.js)
|
||||
export function utilFetchJson(resourse, init) {
|
||||
return fetch(resourse, init)
|
||||
.then((response) => {
|
||||
// fetch in PhantomJS tests may return ok=false and status=0 even if it's okay
|
||||
if ((!response.ok && response.status !== 0) || !response.json) throw new Error(response.status + ' ' + response.statusText);
|
||||
if (response.status === 204 || response.status === 205) return;
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user