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:
Quincy Morgan
2021-02-23 11:50:00 -05:00
parent 997b453b98
commit 13ddeecfa7
5 changed files with 40 additions and 41 deletions
+2 -2
View File
@@ -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) {
+1
View File
@@ -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';
+11
View File
@@ -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();
});
}