Skip to content

Commit 4116a0c

Browse files
committed
Fixing the tests and the AbortController usage to be compatible with new fetch-mock package (based on @wheresrhys suggestion).
1 parent 6139087 commit 4116a0c

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"eslint-plugin-promise": "^7.2.1",
134134
"eslint-plugin-react": "^7.37.5",
135135
"eslint-plugin-standard": "^5.0.0",
136-
"fetch-mock": "12.5.5",
136+
"fetch-mock": "12.6.0",
137137
"file-loader": "^6.2.0",
138138
"git-revision-webpack-plugin": "^5.0.0",
139139
"globals": "^16.4.0",

src/helpers/common.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const EMPTY_FNC = () => {};
1010
export const identity = x => x;
1111

1212
/**
13-
* Safe getter to traverse compex object/array structures.
13+
* Safe getter to traverse complex object/array structures.
1414
* @param {*} obj the root of the structure being traversed (object, array)
1515
* @param {Array} path sequence of steps, each step is either an explicit key or a function;
1616
* function can be only used in arrays and they are applied as .find() callbacks
@@ -116,7 +116,7 @@ export const unique = arr => [...new Set(arr)];
116116

117117
/**
118118
* Get an array of strings, return object where keys are that strings
119-
* and values are lists of indices refering to the positions in original array.
119+
* and values are lists of indices referring to the positions in original array.
120120
*/
121121
export const createIndex = arr => {
122122
const index = {};
@@ -162,7 +162,7 @@ export const objectKeyMap = (obj, fnc) => {
162162
* Search object by values and return corresponding key.
163163
* @param {Object} obj object to be searched
164164
* @param {*} predicate either a value being searched or a function that tests each value and returns true if match is found
165-
* @returns {string|number} key of the first matchinng value (beware the order of search is implementation specific)
165+
* @returns {string|number} key of the first matching value (beware the order of search is implementation specific)
166166
*/
167167
export const objectFind = (obj, predicate) =>
168168
Object.keys(obj).find(typeof predicate === 'function' ? key => predicate(obj[key]) : key => obj[key] === predicate);
@@ -215,14 +215,14 @@ const _defaultComparator = (a, b) => {
215215
* @param {function} comparator Comparator that determines ordering. Same as in case of sort() method.
216216
* @return Smallest (the first) item of the array in given ordering.
217217
*/
218-
export const getFirstItemInOrder = (arr, comarator = _defaultComparator) => {
218+
export const getFirstItemInOrder = (arr, comparator = _defaultComparator) => {
219219
if (!arr || !Array.isArray(arr) || arr.length === 0) {
220220
return null;
221221
}
222222

223223
let res = arr[0];
224224
arr.forEach((item, idx) => {
225-
if (idx > 0 && comarator(res, item) > 0) {
225+
if (idx > 0 && comparator(res, item) > 0) {
226226
res = item;
227227
}
228228
});

src/redux/helpers/api/tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const encodeBody = (body, method, encodeAsMultipart) => {
9191
return undefined; // other methods do not have a body
9292
};
9393

94-
let requestAbortController = canUseDOM && 'AbortController' in window ? new window.AbortController() : null;
94+
let requestAbortController = canUseDOM && 'AbortController' in globalThis ? new globalThis.AbortController() : null;
9595

9696
export const createRequest = (endpoint, query = {}, method, headers, body, uploadFiles) =>
9797
fetch(getUrl(assembleEndpoint(endpoint, query)), {
@@ -105,7 +105,7 @@ export const abortAllPendingRequests = () => {
105105
if (requestAbortController) {
106106
requestAbortController.abort();
107107
}
108-
requestAbortController = canUseDOM && 'AbortController' in window ? new window.AbortController() : null;
108+
requestAbortController = canUseDOM && 'AbortController' in globalThis ? new globalThis.AbortController() : null;
109109
};
110110

111111
export const getHeaders = (headers, accessToken, skipContentType) => {

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7974,15 +7974,15 @@ __metadata:
79747974
languageName: node
79757975
linkType: hard
79767976

7977-
"fetch-mock@npm:12.5.5":
7978-
version: 12.5.5
7979-
resolution: "fetch-mock@npm:12.5.5"
7977+
"fetch-mock@npm:12.6.0":
7978+
version: 12.6.0
7979+
resolution: "fetch-mock@npm:12.6.0"
79807980
dependencies:
79817981
"@types/glob-to-regexp": ^0.4.4
79827982
dequal: ^2.0.3
79837983
glob-to-regexp: ^0.4.1
79847984
regexparam: ^3.0.0
7985-
checksum: 6208561b601e0aead7e8abcb6a4b9ad59679c185f20ffe47105f7126c30646169ff7bae3cc728b0581b9b74d2800dc45320aec4f554992b5618f9b2a816937dc
7985+
checksum: 7705aaa6ab149f59e10e9e0794175e31c3b6c52eb0aab22522a4d7689a1ff0e3a85b9f76a2079adfd23d515e4db228e9ab7d4293f5c4cfee157cd9f858e14ae1
79867986
languageName: node
79877987
linkType: hard
79887988

@@ -13261,7 +13261,7 @@ __metadata:
1326113261
eslint-plugin-react: ^7.37.5
1326213262
eslint-plugin-standard: ^5.0.0
1326313263
express: ^5.1.0
13264-
fetch-mock: 12.5.5
13264+
fetch-mock: 12.6.0
1326513265
file-loader: ^6.2.0
1326613266
file-saver: ^2.0.5
1326713267
flat: ^6.0.1

0 commit comments

Comments
 (0)