Bump the npm group with 3 updates (#2303)
* --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: sinon dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
ebd27c09f6
commit
b1bd8da5e7
212 changed files with 11182 additions and 16383 deletions
4
node_modules/nise/lib/configure-logger/index.js
generated
vendored
4
node_modules/nise/lib/configure-logger/index.js
generated
vendored
|
|
@ -11,7 +11,7 @@ function configureLogger(config) {
|
|||
// Function which prints errors.
|
||||
if (!config.hasOwnProperty("logger")) {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
config.logger = function() {};
|
||||
config.logger = function () {};
|
||||
}
|
||||
// When set to true, any errors logged will be thrown immediately;
|
||||
// If set to false, the errors will be thrown in separate execution frame.
|
||||
|
|
@ -28,7 +28,7 @@ function configureLogger(config) {
|
|||
var err = {
|
||||
name: e.name || label,
|
||||
message: e.message || e.toString(),
|
||||
stack: e.stack
|
||||
stack: e.stack,
|
||||
};
|
||||
|
||||
function throwLoggedError() {
|
||||
|
|
|
|||
24
node_modules/nise/lib/event/event-target.js
generated
vendored
24
node_modules/nise/lib/event/event-target.js
generated
vendored
|
|
@ -5,22 +5,22 @@ function flattenOptions(options) {
|
|||
return {
|
||||
capture: Boolean(options),
|
||||
once: false,
|
||||
passive: false
|
||||
passive: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
capture: Boolean(options.capture),
|
||||
once: Boolean(options.once),
|
||||
passive: Boolean(options.passive)
|
||||
passive: Boolean(options.passive),
|
||||
};
|
||||
}
|
||||
function not(fn) {
|
||||
return function() {
|
||||
return function () {
|
||||
return !fn.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
function hasListenerFilter(listener, capture) {
|
||||
return function(listenerSpec) {
|
||||
return function (listenerSpec) {
|
||||
return (
|
||||
listenerSpec.capture === capture &&
|
||||
listenerSpec.listener === listener
|
||||
|
|
@ -33,7 +33,7 @@ var EventTarget = {
|
|||
addEventListener: function addEventListener(
|
||||
event,
|
||||
listener,
|
||||
providedOptions
|
||||
providedOptions,
|
||||
) {
|
||||
// 3. Let capture, passive, and once be the result of flattening more options.
|
||||
// Flatten property before executing step 2,
|
||||
|
|
@ -59,13 +59,13 @@ var EventTarget = {
|
|||
// callback, capture is capture, passive is passive, and once is once.
|
||||
if (
|
||||
!this.eventListeners[event].some(
|
||||
hasListenerFilter(listener, options.capture)
|
||||
hasListenerFilter(listener, options.capture),
|
||||
)
|
||||
) {
|
||||
this.eventListeners[event].push({
|
||||
listener: listener,
|
||||
capture: options.capture,
|
||||
once: options.once
|
||||
once: options.once,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -74,7 +74,7 @@ var EventTarget = {
|
|||
removeEventListener: function removeEventListener(
|
||||
event,
|
||||
listener,
|
||||
providedOptions
|
||||
providedOptions,
|
||||
) {
|
||||
if (!this.eventListeners || !this.eventListeners[event]) {
|
||||
return;
|
||||
|
|
@ -88,7 +88,7 @@ var EventTarget = {
|
|||
// and capture is capture, then set that event listener’s
|
||||
// removed to true and remove it from the associated list of event listeners.
|
||||
this.eventListeners[event] = this.eventListeners[event].filter(
|
||||
not(hasListenerFilter(listener, options.capture))
|
||||
not(hasListenerFilter(listener, options.capture)),
|
||||
);
|
||||
},
|
||||
|
||||
|
|
@ -103,10 +103,10 @@ var EventTarget = {
|
|||
|
||||
// Remove listeners, that should be dispatched once
|
||||
// before running dispatch loop to avoid nested dispatch issues
|
||||
self.eventListeners[type] = listeners.filter(function(listenerSpec) {
|
||||
self.eventListeners[type] = listeners.filter(function (listenerSpec) {
|
||||
return !listenerSpec.once;
|
||||
});
|
||||
listeners.forEach(function(listenerSpec) {
|
||||
listeners.forEach(function (listenerSpec) {
|
||||
var listener = listenerSpec.listener;
|
||||
if (typeof listener === "function") {
|
||||
listener.call(self, event);
|
||||
|
|
@ -116,7 +116,7 @@ var EventTarget = {
|
|||
});
|
||||
|
||||
return Boolean(event.defaultPrevented);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = EventTarget;
|
||||
|
|
|
|||
8
node_modules/nise/lib/event/event.js
generated
vendored
8
node_modules/nise/lib/event/event.js
generated
vendored
|
|
@ -5,7 +5,7 @@ function Event(type, bubbles, cancelable, target) {
|
|||
}
|
||||
|
||||
Event.prototype = {
|
||||
initEvent: function(type, bubbles, cancelable, target) {
|
||||
initEvent: function (type, bubbles, cancelable, target) {
|
||||
this.type = type;
|
||||
this.bubbles = bubbles;
|
||||
this.cancelable = cancelable;
|
||||
|
|
@ -14,11 +14,11 @@ Event.prototype = {
|
|||
},
|
||||
|
||||
// eslint-disable-next-line no-empty-function
|
||||
stopPropagation: function() {},
|
||||
stopPropagation: function () {},
|
||||
|
||||
preventDefault: function() {
|
||||
preventDefault: function () {
|
||||
this.defaultPrevented = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = Event;
|
||||
|
|
|
|||
2
node_modules/nise/lib/event/index.js
generated
vendored
2
node_modules/nise/lib/event/index.js
generated
vendored
|
|
@ -4,5 +4,5 @@ module.exports = {
|
|||
Event: require("./event"),
|
||||
ProgressEvent: require("./progress-event"),
|
||||
CustomEvent: require("./custom-event"),
|
||||
EventTarget: require("./event-target")
|
||||
EventTarget: require("./event-target"),
|
||||
};
|
||||
|
|
|
|||
8
node_modules/nise/lib/fake-server/fake-server-with-clock.js
generated
vendored
8
node_modules/nise/lib/fake-server/fake-server-with-clock.js
generated
vendored
|
|
@ -23,19 +23,19 @@ fakeServerWithClock.addRequest = function addRequest(xhr) {
|
|||
var clockSetInterval = this.clock.setInterval;
|
||||
var server = this;
|
||||
|
||||
this.clock.setTimeout = function(fn, timeout) {
|
||||
this.clock.setTimeout = function (fn, timeout) {
|
||||
server.longestTimeout = Math.max(
|
||||
timeout,
|
||||
server.longestTimeout || 0
|
||||
server.longestTimeout || 0,
|
||||
);
|
||||
|
||||
return clockSetTimeout.apply(this, arguments);
|
||||
};
|
||||
|
||||
this.clock.setInterval = function(fn, timeout) {
|
||||
this.clock.setInterval = function (fn, timeout) {
|
||||
server.longestTimeout = Math.max(
|
||||
timeout,
|
||||
server.longestTimeout || 0
|
||||
server.longestTimeout || 0,
|
||||
);
|
||||
|
||||
return clockSetInterval.apply(this, arguments);
|
||||
|
|
|
|||
76
node_modules/nise/lib/fake-server/index.js
generated
vendored
76
node_modules/nise/lib/fake-server/index.js
generated
vendored
|
|
@ -4,7 +4,7 @@ var fakeXhr = require("../fake-xhr");
|
|||
var push = [].push;
|
||||
var log = require("./log");
|
||||
var configureLogError = require("../configure-logger");
|
||||
var pathToRegexp = require("path-to-regexp");
|
||||
var pathToRegexp = require("path-to-regexp").pathToRegexp;
|
||||
|
||||
var supportsArrayBuffer = typeof ArrayBuffer !== "undefined";
|
||||
|
||||
|
|
@ -18,11 +18,11 @@ function responseArray(handler) {
|
|||
if (typeof response[2] !== "string") {
|
||||
if (!supportsArrayBuffer) {
|
||||
throw new TypeError(
|
||||
`Fake server response body should be a string, but was ${typeof response[2]}`
|
||||
`Fake server response body should be a string, but was ${typeof response[2]}`,
|
||||
);
|
||||
} else if (!(response[2] instanceof ArrayBuffer)) {
|
||||
throw new TypeError(
|
||||
`Fake server response body should be a string or ArrayBuffer, but was ${typeof response[2]}`
|
||||
`Fake server response body should be a string or ArrayBuffer, but was ${typeof response[2]}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ function getDefaultWindowLocation() {
|
|||
var winloc = {
|
||||
hostname: "localhost",
|
||||
port: process.env.PORT || 80,
|
||||
protocol: "http:"
|
||||
protocol: "http:",
|
||||
};
|
||||
winloc.host =
|
||||
winloc.hostname +
|
||||
|
|
@ -94,7 +94,7 @@ function match(response, request) {
|
|||
var args = [request].concat(
|
||||
ru && typeof ru.exec === "function"
|
||||
? ru.exec(requestUrl).slice(1)
|
||||
: []
|
||||
: [],
|
||||
);
|
||||
return response.response.apply(response, args);
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ function incrementRequestCount() {
|
|||
}
|
||||
|
||||
var fakeServer = {
|
||||
create: function(config) {
|
||||
create: function (config) {
|
||||
var server = Object.create(this);
|
||||
server.configure(config);
|
||||
this.xhr = fakeXhr.useFakeXMLHttpRequest();
|
||||
|
|
@ -131,8 +131,8 @@ var fakeServer = {
|
|||
server.queue = [];
|
||||
server.responses = [];
|
||||
|
||||
this.xhr.onCreate = function(xhrObj) {
|
||||
xhrObj.unsafeHeadersEnabled = function() {
|
||||
this.xhr.onCreate = function (xhrObj) {
|
||||
xhrObj.unsafeHeadersEnabled = function () {
|
||||
return !(server.unsafeHeadersEnabled === false);
|
||||
};
|
||||
server.addRequest(xhrObj);
|
||||
|
|
@ -141,7 +141,7 @@ var fakeServer = {
|
|||
return server;
|
||||
},
|
||||
|
||||
configure: function(config) {
|
||||
configure: function (config) {
|
||||
var self = this;
|
||||
var allowlist = {
|
||||
autoRespond: true,
|
||||
|
|
@ -149,13 +149,14 @@ var fakeServer = {
|
|||
respondImmediately: true,
|
||||
fakeHTTPMethods: true,
|
||||
logger: true,
|
||||
unsafeHeadersEnabled: true
|
||||
unsafeHeadersEnabled: true,
|
||||
legacyRoutes: true,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
config = config || {};
|
||||
|
||||
Object.keys(config).forEach(function(setting) {
|
||||
Object.keys(config).forEach(function (setting) {
|
||||
if (setting in allowlist) {
|
||||
self[setting] = config[setting];
|
||||
}
|
||||
|
|
@ -170,13 +171,13 @@ var fakeServer = {
|
|||
|
||||
incrementRequestCount.call(this);
|
||||
|
||||
xhrObj.onSend = function() {
|
||||
xhrObj.onSend = function () {
|
||||
server.handleRequest(this);
|
||||
|
||||
if (server.respondImmediately) {
|
||||
server.respond();
|
||||
} else if (server.autoRespond && !server.responding) {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
server.responding = false;
|
||||
server.respond();
|
||||
}, server.autoRespondAfter || 10);
|
||||
|
|
@ -189,7 +190,7 @@ var fakeServer = {
|
|||
getHTTPMethod: function getHTTPMethod(request) {
|
||||
if (this.fakeHTTPMethods && /post/i.test(request.method)) {
|
||||
var matches = (request.requestBody || "").match(
|
||||
/_method=([^\b;]+)/
|
||||
/_method=([^\b;]+)/,
|
||||
);
|
||||
return matches ? matches[1] : request.method;
|
||||
}
|
||||
|
|
@ -205,7 +206,7 @@ var fakeServer = {
|
|||
}
|
||||
},
|
||||
|
||||
logger: function() {
|
||||
logger: function () {
|
||||
// no-op; override via configure()
|
||||
},
|
||||
|
||||
|
|
@ -213,6 +214,8 @@ var fakeServer = {
|
|||
|
||||
log: log,
|
||||
|
||||
legacyRoutes: true,
|
||||
|
||||
respondWith: function respondWith(method, url, body) {
|
||||
if (arguments.length === 1 && typeof method !== "function") {
|
||||
this.response = responseArray(method);
|
||||
|
|
@ -236,17 +239,34 @@ var fakeServer = {
|
|||
}
|
||||
|
||||
// Escape port number to prevent "named" parameters in 'path-to-regexp' module
|
||||
if (typeof url === "string" && url !== "" && /:[0-9]+\//.test(url)) {
|
||||
var m = url.match(/^(https?:\/\/.*?):([0-9]+\/.*)$/);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = `${m[1]}\\:${m[2]}`;
|
||||
if (typeof url === "string" && url !== "") {
|
||||
if (/:[0-9]+\//.test(url)) {
|
||||
var m = url.match(/^(https?:\/\/.*?):([0-9]+\/.*)$/);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = `${m[1]}\\:${m[2]}`;
|
||||
}
|
||||
if (/:\/\//.test(url)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = url.replace("://", "\\://");
|
||||
}
|
||||
if (/\*/.test(url)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = url.replace(/\/\*/g, "/(.*)");
|
||||
}
|
||||
|
||||
if (this.legacyRoutes) {
|
||||
if (url.includes("?")) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
url = url.replace("?", "\\?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push.call(this.responses, {
|
||||
method: method,
|
||||
url:
|
||||
typeof url === "string" && url !== "" ? pathToRegexp(url) : url,
|
||||
response: typeof body === "function" ? body : responseArray(body)
|
||||
response: typeof body === "function" ? body : responseArray(body),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -259,7 +279,7 @@ var fakeServer = {
|
|||
var requests = queue.splice(0, queue.length);
|
||||
var self = this;
|
||||
|
||||
requests.forEach(function(request) {
|
||||
requests.forEach(function (request) {
|
||||
self.processRequest(request);
|
||||
});
|
||||
},
|
||||
|
|
@ -324,10 +344,18 @@ var fakeServer = {
|
|||
resetHistory: function resetHistory() {
|
||||
this.requests.length = this.requestCount = 0;
|
||||
|
||||
this.requestedOnce = this.requestedTwice = this.requestedThrice = this.requested = false;
|
||||
this.requestedOnce =
|
||||
this.requestedTwice =
|
||||
this.requestedThrice =
|
||||
this.requested =
|
||||
false;
|
||||
|
||||
this.firstRequest = this.secondRequest = this.thirdRequest = this.lastRequest = null;
|
||||
}
|
||||
this.firstRequest =
|
||||
this.secondRequest =
|
||||
this.thirdRequest =
|
||||
this.lastRequest =
|
||||
null;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = fakeServer;
|
||||
|
|
|
|||
2
node_modules/nise/lib/fake-xhr/blob.js
generated
vendored
2
node_modules/nise/lib/fake-xhr/blob.js
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
exports.isSupported = (function() {
|
||||
exports.isSupported = (function () {
|
||||
try {
|
||||
return Boolean(new Blob());
|
||||
} catch (e) {
|
||||
|
|
|
|||
111
node_modules/nise/lib/fake-xhr/index.js
generated
vendored
111
node_modules/nise/lib/fake-xhr/index.js
generated
vendored
|
|
@ -23,7 +23,7 @@ function getWorkingXHR(globalScope) {
|
|||
|
||||
var supportsActiveX = typeof globalScope.ActiveXObject !== "undefined";
|
||||
if (supportsActiveX) {
|
||||
return function() {
|
||||
return function () {
|
||||
return new globalScope.ActiveXObject("MSXML2.XMLHTTP.3.0");
|
||||
};
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ var unsafeHeaders = {
|
|||
"Transfer-Encoding": true,
|
||||
Upgrade: true,
|
||||
"User-Agent": true,
|
||||
Via: true
|
||||
Via: true,
|
||||
};
|
||||
|
||||
function EventTargetHandler() {
|
||||
|
|
@ -66,11 +66,11 @@ function EventTargetHandler() {
|
|||
"error",
|
||||
"load",
|
||||
"timeout",
|
||||
"loadend"
|
||||
"loadend",
|
||||
];
|
||||
|
||||
function addEventListener(eventName) {
|
||||
self.addEventListener(eventName, function(event) {
|
||||
self.addEventListener(eventName, function (event) {
|
||||
var listener = self[`on${eventName}`];
|
||||
|
||||
if (listener && typeof listener === "function") {
|
||||
|
|
@ -91,7 +91,7 @@ function normalizeHeaderValue(value) {
|
|||
}
|
||||
|
||||
function getHeader(headers, header) {
|
||||
var foundHeader = Object.keys(headers).filter(function(h) {
|
||||
var foundHeader = Object.keys(headers).filter(function (h) {
|
||||
return h.toLowerCase() === header.toLowerCase();
|
||||
});
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ function verifyResponseBodyType(body, responseType) {
|
|||
if (responseType === "arraybuffer") {
|
||||
if (!isString && !(body instanceof ArrayBuffer)) {
|
||||
error = new Error(
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string or ArrayBuffer.`
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string or ArrayBuffer.`,
|
||||
);
|
||||
error.name = "InvalidBodyException";
|
||||
}
|
||||
|
|
@ -121,13 +121,13 @@ function verifyResponseBodyType(body, responseType) {
|
|||
!(body instanceof Blob)
|
||||
) {
|
||||
error = new Error(
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string, ArrayBuffer, or Blob.`
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string, ArrayBuffer, or Blob.`,
|
||||
);
|
||||
error.name = "InvalidBodyException";
|
||||
}
|
||||
} else if (!isString) {
|
||||
error = new Error(
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string.`
|
||||
`Attempted to respond to fake XMLHttpRequest with ${body}, which is not a string.`,
|
||||
);
|
||||
error.name = "InvalidBodyException";
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
}
|
||||
|
||||
// largest arity in XHR is 5 - XHR#open
|
||||
var apply = function(obj, method, args) {
|
||||
var apply = function (obj, method, args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return obj[method]();
|
||||
|
|
@ -254,14 +254,14 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
"getAllResponseHeaders",
|
||||
"addEventListener",
|
||||
"overrideMimeType",
|
||||
"removeEventListener"
|
||||
].forEach(function(method) {
|
||||
fakeXhr[method] = function() {
|
||||
"removeEventListener",
|
||||
].forEach(function (method) {
|
||||
fakeXhr[method] = function () {
|
||||
return apply(xhr, method, arguments);
|
||||
};
|
||||
});
|
||||
|
||||
fakeXhr.send = function() {
|
||||
fakeXhr.send = function () {
|
||||
// Ref: https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
||||
if (xhr.responseType !== fakeXhr.responseType) {
|
||||
xhr.responseType = fakeXhr.responseType;
|
||||
|
|
@ -269,13 +269,13 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
return apply(xhr, "send", arguments);
|
||||
};
|
||||
|
||||
var copyAttrs = function(args) {
|
||||
args.forEach(function(attr) {
|
||||
var copyAttrs = function (args) {
|
||||
args.forEach(function (attr) {
|
||||
fakeXhr[attr] = xhr[attr];
|
||||
});
|
||||
};
|
||||
|
||||
var stateChangeStart = function() {
|
||||
var stateChangeStart = function () {
|
||||
fakeXhr.readyState = xhr.readyState;
|
||||
if (xhr.readyState >= FakeXMLHttpRequest.HEADERS_RECEIVED) {
|
||||
copyAttrs(["status", "statusText"]);
|
||||
|
|
@ -294,12 +294,12 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
}
|
||||
};
|
||||
|
||||
var stateChangeEnd = function() {
|
||||
var stateChangeEnd = function () {
|
||||
if (fakeXhr.onreadystatechange) {
|
||||
// eslint-disable-next-line no-useless-call
|
||||
fakeXhr.onreadystatechange.call(fakeXhr, {
|
||||
target: fakeXhr,
|
||||
currentTarget: fakeXhr
|
||||
currentTarget: fakeXhr,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -312,12 +312,12 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
if (xhr.addEventListener) {
|
||||
xhr.addEventListener("readystatechange", stateChangeStart);
|
||||
|
||||
Object.keys(fakeXhr.eventListeners).forEach(function(event) {
|
||||
Object.keys(fakeXhr.eventListeners).forEach(function (event) {
|
||||
/*eslint-disable no-loop-func*/
|
||||
fakeXhr.eventListeners[event].forEach(function(handler) {
|
||||
fakeXhr.eventListeners[event].forEach(function (handler) {
|
||||
xhr.addEventListener(event, handler.listener, {
|
||||
capture: handler.capture,
|
||||
once: handler.once
|
||||
once: handler.once,
|
||||
});
|
||||
});
|
||||
/*eslint-enable no-loop-func*/
|
||||
|
|
@ -436,7 +436,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
|
||||
return result.getElementsByTagNameNS(
|
||||
parsererrorNS,
|
||||
"parsererror"
|
||||
"parsererror",
|
||||
).length
|
||||
? null
|
||||
: result;
|
||||
|
|
@ -495,7 +495,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
502: "Bad Gateway",
|
||||
503: "Service Unavailable",
|
||||
504: "Gateway Timeout",
|
||||
505: "HTTP Version Not Supported"
|
||||
505: "HTTP Version Not Supported",
|
||||
};
|
||||
|
||||
extend(FakeXMLHttpRequest.prototype, sinonEvent.EventTarget, {
|
||||
|
|
@ -513,7 +513,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
|
||||
if (FakeXMLHttpRequest.useFilters === true) {
|
||||
var xhrArgs = arguments;
|
||||
var defake = FakeXMLHttpRequest.filters.some(function(filter) {
|
||||
var defake = FakeXMLHttpRequest.filters.some(function (filter) {
|
||||
return filter.apply(this, xhrArgs);
|
||||
});
|
||||
if (defake) {
|
||||
|
|
@ -531,7 +531,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
"readystatechange",
|
||||
false,
|
||||
false,
|
||||
this
|
||||
this,
|
||||
);
|
||||
if (typeof this.onreadystatechange === "function") {
|
||||
try {
|
||||
|
|
@ -559,25 +559,29 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
|
||||
if (supportsProgress) {
|
||||
this.upload.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent("progress", progress, this)
|
||||
new sinonEvent.ProgressEvent(
|
||||
"progress",
|
||||
progress,
|
||||
this,
|
||||
),
|
||||
);
|
||||
this.upload.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent(event, progress, this)
|
||||
new sinonEvent.ProgressEvent(event, progress, this),
|
||||
);
|
||||
this.upload.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent("loadend", progress, this)
|
||||
new sinonEvent.ProgressEvent("loadend", progress, this),
|
||||
);
|
||||
}
|
||||
|
||||
this.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent("progress", progress, this)
|
||||
new sinonEvent.ProgressEvent("progress", progress, this),
|
||||
);
|
||||
this.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent(event, progress, this)
|
||||
new sinonEvent.ProgressEvent(event, progress, this),
|
||||
);
|
||||
this.dispatchEvent(readyStateChangeEvent);
|
||||
this.dispatchEvent(
|
||||
new sinonEvent.ProgressEvent("loadend", progress, this)
|
||||
new sinonEvent.ProgressEvent("loadend", progress, this),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -586,7 +590,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
setRequestHeader: function setRequestHeader(header, value) {
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError(
|
||||
`By RFC7230, section 3.2.4, header values should be strings. Got ${typeof value}`
|
||||
`By RFC7230, section 3.2.4, header values should be strings. Got ${typeof value}`,
|
||||
);
|
||||
}
|
||||
verifyState(this);
|
||||
|
|
@ -603,7 +607,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
) {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line quotes
|
||||
`Refused to set unsafe header "${header}"`
|
||||
`Refused to set unsafe header "${header}"`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -632,7 +636,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
|
||||
var responseHeaders = (this.responseHeaders = {});
|
||||
|
||||
Object.keys(headers).forEach(function(header) {
|
||||
Object.keys(headers).forEach(function (header) {
|
||||
responseHeaders[header] = headers[header];
|
||||
});
|
||||
|
||||
|
|
@ -650,13 +654,12 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
if (!/^(head)$/i.test(this.method)) {
|
||||
var contentType = getHeader(
|
||||
this.requestHeaders,
|
||||
"Content-Type"
|
||||
"Content-Type",
|
||||
);
|
||||
if (this.requestHeaders[contentType]) {
|
||||
var value = this.requestHeaders[contentType].split(";");
|
||||
this.requestHeaders[
|
||||
contentType
|
||||
] = `${value[0]};charset=utf-8`;
|
||||
this.requestHeaders[contentType] =
|
||||
`${value[0]};charset=utf-8`;
|
||||
} else if (supportsFormData && !(data instanceof FormData)) {
|
||||
this.requestHeaders["Content-Type"] =
|
||||
"text/plain;charset=utf-8";
|
||||
|
|
@ -687,7 +690,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
// is in flight, so we must check anytime the end user forces a clock tick to make
|
||||
// sure timeout hasn't changed.
|
||||
// https://xhr.spec.whatwg.org/#dfnReturnLink-2
|
||||
var clearIntervalId = setInterval(function() {
|
||||
var clearIntervalId = setInterval(function () {
|
||||
// Check if the readyState has been reset or is done. If this is the case, there
|
||||
// should be no timeout. This will also prevent aborted requests and
|
||||
// fakeServerWithClock from triggering unnecessary responses.
|
||||
|
|
@ -709,7 +712,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
}
|
||||
|
||||
this.dispatchEvent(
|
||||
new sinonEvent.Event("loadstart", false, false, this)
|
||||
new sinonEvent.Event("loadstart", false, false, this),
|
||||
);
|
||||
},
|
||||
|
||||
|
|
@ -719,7 +722,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
this.readyState = FakeXMLHttpRequest.UNSENT;
|
||||
},
|
||||
|
||||
error: function() {
|
||||
error: function () {
|
||||
clearResponse(this);
|
||||
this.errorFlag = true;
|
||||
this.requestHeaders = {};
|
||||
|
|
@ -758,7 +761,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
var responseHeaders = this.responseHeaders;
|
||||
var headers = Object.keys(responseHeaders)
|
||||
.filter(excludeSetCookie2Header)
|
||||
.reduce(function(prev, header) {
|
||||
.reduce(function (prev, header) {
|
||||
var value = responseHeaders[header];
|
||||
|
||||
return `${prev}${header}: ${value}\r\n`;
|
||||
|
|
@ -788,7 +791,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
if (isTextResponse) {
|
||||
this.responseText = this.response += body.substring(
|
||||
index,
|
||||
index + chunkSize
|
||||
index + chunkSize,
|
||||
);
|
||||
}
|
||||
index += chunkSize;
|
||||
|
|
@ -798,7 +801,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
this.response = convertResponseBody(
|
||||
this.responseType,
|
||||
contentType,
|
||||
body
|
||||
body,
|
||||
);
|
||||
if (isTextResponse) {
|
||||
this.responseText = this.response;
|
||||
|
|
@ -811,7 +814,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
isXmlContentType(contentType)
|
||||
) {
|
||||
this.responseXML = FakeXMLHttpRequest.parseXML(
|
||||
this.responseText
|
||||
this.responseText,
|
||||
);
|
||||
}
|
||||
this.readyStateChange(FakeXMLHttpRequest.DONE);
|
||||
|
|
@ -831,8 +834,8 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
new sinonEvent.ProgressEvent(
|
||||
"progress",
|
||||
progressEventRaw,
|
||||
this.upload
|
||||
)
|
||||
this.upload,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -843,8 +846,8 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
new sinonEvent.ProgressEvent(
|
||||
"progress",
|
||||
progressEventRaw,
|
||||
this
|
||||
)
|
||||
this,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -852,7 +855,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
uploadError: function uploadError(error) {
|
||||
if (supportsCustomEvent) {
|
||||
this.upload.dispatchEvent(
|
||||
new sinonEvent.CustomEvent("error", { detail: error })
|
||||
new sinonEvent.CustomEvent("error", { detail: error }),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -862,7 +865,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
throw new Error("INVALID_STATE_ERR");
|
||||
}
|
||||
this.overriddenMimeType = type;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var states = {
|
||||
|
|
@ -870,7 +873,7 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
OPENED: 1,
|
||||
HEADERS_RECEIVED: 2,
|
||||
LOADING: 3,
|
||||
DONE: 4
|
||||
DONE: 4,
|
||||
};
|
||||
|
||||
extend(FakeXMLHttpRequest, states);
|
||||
|
|
@ -915,10 +918,10 @@ function fakeXMLHttpRequestFor(globalScope) {
|
|||
return {
|
||||
xhr: sinonXhr,
|
||||
FakeXMLHttpRequest: FakeXMLHttpRequest,
|
||||
useFakeXMLHttpRequest: useFakeXMLHttpRequest
|
||||
useFakeXMLHttpRequest: useFakeXMLHttpRequest,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = extend(fakeXMLHttpRequestFor(globalObject), {
|
||||
fakeXMLHttpRequestFor: fakeXMLHttpRequestFor
|
||||
fakeXMLHttpRequestFor: fakeXMLHttpRequestFor,
|
||||
});
|
||||
|
|
|
|||
2
node_modules/nise/lib/index.js
generated
vendored
2
node_modules/nise/lib/index.js
generated
vendored
|
|
@ -3,5 +3,5 @@
|
|||
module.exports = {
|
||||
fakeServer: require("./fake-server"),
|
||||
fakeServerWithClock: require("./fake-server/fake-server-with-clock"),
|
||||
fakeXhr: require("./fake-xhr")
|
||||
fakeXhr: require("./fake-xhr"),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue