fetch-mock
Advanced tools
Comparing version 4.5.3 to 4.5.4
@@ -24,8 +24,8 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fetchMock = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var Headers = undefined; | ||
var Request = undefined; | ||
var Response = undefined; | ||
var stream = undefined; | ||
var theGlobal = undefined; | ||
var statusTextMap = undefined; | ||
var Headers = void 0; | ||
var Request = void 0; | ||
var Response = void 0; | ||
var stream = void 0; | ||
var theGlobal = void 0; | ||
var statusTextMap = void 0; | ||
@@ -147,3 +147,3 @@ /** | ||
var matchUrl = undefined; | ||
var matchUrl = void 0; | ||
@@ -208,3 +208,2 @@ if (typeof route.matcher === 'string') { | ||
this.reset = this.reset.bind(this); | ||
this.realFetch = theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
} | ||
@@ -237,4 +236,5 @@ | ||
value: function mock(matcher, method, response) { | ||
var config = undefined; | ||
// Do this here rather than in the constructor to ensure it's scoped to the test | ||
this.realFetch = this.realFetch || theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
var config = void 0; | ||
// Handle the variety of parameters accepted by mock (see README) | ||
@@ -329,3 +329,3 @@ if (response) { | ||
value: function router(url, opts) { | ||
var route = undefined; | ||
var route = void 0; | ||
for (var i = 0, il = this.routes.length; i < il; i++) { | ||
@@ -389,3 +389,5 @@ route = this.routes[i]; | ||
value: function restore() { | ||
theGlobal.fetch = this.realFetch; | ||
if (this.realFetch) { | ||
theGlobal.fetch = this.realFetch; | ||
} | ||
this.reset(); | ||
@@ -392,0 +394,0 @@ this.routes = []; |
@@ -9,8 +9,8 @@ 'use strict'; | ||
var Headers = undefined; | ||
var Request = undefined; | ||
var Response = undefined; | ||
var stream = undefined; | ||
var theGlobal = undefined; | ||
var statusTextMap = undefined; | ||
var Headers = void 0; | ||
var Request = void 0; | ||
var Response = void 0; | ||
var stream = void 0; | ||
var theGlobal = void 0; | ||
var statusTextMap = void 0; | ||
@@ -132,3 +132,3 @@ /** | ||
var matchUrl = undefined; | ||
var matchUrl = void 0; | ||
@@ -193,3 +193,2 @@ if (typeof route.matcher === 'string') { | ||
this.reset = this.reset.bind(this); | ||
this.realFetch = theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
} | ||
@@ -222,4 +221,5 @@ | ||
value: function mock(matcher, method, response) { | ||
var config = undefined; | ||
// Do this here rather than in the constructor to ensure it's scoped to the test | ||
this.realFetch = this.realFetch || theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
var config = void 0; | ||
// Handle the variety of parameters accepted by mock (see README) | ||
@@ -314,3 +314,3 @@ if (response) { | ||
value: function router(url, opts) { | ||
var route = undefined; | ||
var route = void 0; | ||
for (var i = 0, il = this.routes.length; i < il; i++) { | ||
@@ -374,3 +374,5 @@ route = this.routes[i]; | ||
value: function restore() { | ||
theGlobal.fetch = this.realFetch; | ||
if (this.realFetch) { | ||
theGlobal.fetch = this.realFetch; | ||
} | ||
this.reset(); | ||
@@ -377,0 +379,0 @@ this.routes = []; |
{ | ||
"name": "fetch-mock", | ||
"version": "4.5.3", | ||
"version": "4.5.4", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -5,0 +5,0 @@ "main": "src/server.js", |
@@ -174,3 +174,2 @@ 'use strict'; | ||
this.reset = this.reset.bind(this); | ||
this.realFetch = theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
} | ||
@@ -196,3 +195,4 @@ | ||
mock (matcher, method, response) { | ||
// Do this here rather than in the constructor to ensure it's scoped to the test | ||
this.realFetch = this.realFetch || (theGlobal.fetch && theGlobal.fetch.bind(theGlobal)); | ||
let config; | ||
@@ -331,3 +331,5 @@ // Handle the variety of parameters accepted by mock (see README) | ||
restore () { | ||
theGlobal.fetch = this.realFetch; | ||
if (this.realFetch) { | ||
theGlobal.fetch = this.realFetch; | ||
} | ||
this.reset(); | ||
@@ -334,0 +336,0 @@ this.routes = []; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85832
2284