fetch-mock
Advanced tools
Comparing version 9.1.2 to 9.2.0
@@ -83,3 +83,12 @@ const { debug, setDebugPhase } = require('./debug'); | ||
}; | ||
const defineGreedyShorthand = (methodName, underlyingMethod) => { | ||
FetchMock[methodName] = function(response, options) { | ||
return this[underlyingMethod]({}, response, options); | ||
}; | ||
}; | ||
defineShorthand('once', 'mock', { repeat: 1 }); | ||
defineGreedyShorthand('any', 'mock'); | ||
defineGreedyShorthand('anyOnce', 'once'); | ||
@@ -89,2 +98,4 @@ ['get', 'post', 'put', 'delete', 'head', 'patch'].forEach(method => { | ||
defineShorthand(`${method}Once`, 'once', { method }); | ||
defineGreedyShorthand(`${method}Any`, method); | ||
defineGreedyShorthand(`${method}AnyOnce`, `${method}Once`); | ||
}); | ||
@@ -91,0 +102,0 @@ |
@@ -95,3 +95,12 @@ 'use strict'; | ||
}; | ||
var defineGreedyShorthand = function defineGreedyShorthand(methodName, underlyingMethod) { | ||
FetchMock[methodName] = function (response, options) { | ||
return this[underlyingMethod]({}, response, options); | ||
}; | ||
}; | ||
defineShorthand('once', 'mock', { repeat: 1 }); | ||
defineGreedyShorthand('any', 'mock'); | ||
defineGreedyShorthand('anyOnce', 'once'); | ||
@@ -101,2 +110,4 @@ ['get', 'post', 'put', 'delete', 'head', 'patch'].forEach(function (method) { | ||
defineShorthand(method + 'Once', 'once', { method: method }); | ||
defineGreedyShorthand(method + 'Any', method); | ||
defineGreedyShorthand(method + 'AnyOnce', method + 'Once'); | ||
}); | ||
@@ -103,0 +114,0 @@ |
{ | ||
"name": "fetch-mock", | ||
"type": "module", | ||
"version": "9.1.2", | ||
"version": "9.2.0", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -6,0 +6,0 @@ "main": "./cjs/server.js", |
@@ -8,3 +8,3 @@ # fetch-mock | ||
- helpers for all common http methods and for responding a limited number of times | ||
- declarative matching for most aspects of a http request | ||
- declarative matching for most aspects of a http request | ||
- delayed responses | ||
@@ -14,3 +14,3 @@ - spying on real network requests | ||
*New* If using jest, try the new [fetch-mock-jest](https://www.npmjs.com/package/fetch-mock-jest) wrapper. | ||
_New_ If using jest, try the new [fetch-mock-jest](https://www.npmjs.com/package/fetch-mock-jest) wrapper. | ||
@@ -17,0 +17,0 @@ ![node version](https://img.shields.io/node/v/fetch-mock.svg?style=flat-square) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
2804421
80855