fetch-mock
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -355,2 +355,5 @@ (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){ | ||
opts.sendAsJson = responseConfig.sendAsJson === undefined ? this.config.sendAsJson : responseConfig.sendAsJson; | ||
if (responseConfig.status && (typeof responseConfig.status !== 'number' || parseInt(responseConfig.status, 10) !== responseConfig.status || responseConfig.status < 200 || responseConfig.status > 599)) { | ||
throw new TypeError('Invalid status ' + responseConfig.status + ' passed on response object.\nTo respond with a JSON object that has status as a property assign the object to body\ne.g. {"body": {"status: "registered"}}'); | ||
} | ||
opts.status = responseConfig.status || 200; | ||
@@ -357,0 +360,0 @@ opts.statusText = statusTextMap['' + opts.status]; |
@@ -340,2 +340,5 @@ 'use strict'; | ||
opts.sendAsJson = responseConfig.sendAsJson === undefined ? this.config.sendAsJson : responseConfig.sendAsJson; | ||
if (responseConfig.status && (typeof responseConfig.status !== 'number' || parseInt(responseConfig.status, 10) !== responseConfig.status || responseConfig.status < 200 || responseConfig.status > 599)) { | ||
throw new TypeError('Invalid status ' + responseConfig.status + ' passed on response object.\nTo respond with a JSON object that has status as a property assign the object to body\ne.g. {"body": {"status: "registered"}}'); | ||
} | ||
opts.status = responseConfig.status || 200; | ||
@@ -342,0 +345,0 @@ opts.statusText = statusTextMap['' + opts.status]; |
{ | ||
"name": "fetch-mock", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -5,0 +5,0 @@ "main": "src/server.js", |
@@ -298,2 +298,7 @@ 'use strict'; | ||
opts.sendAsJson = responseConfig.sendAsJson === undefined ? this.config.sendAsJson : responseConfig.sendAsJson; | ||
if (responseConfig.status && (typeof responseConfig.status !== 'number' || parseInt(responseConfig.status, 10) !== responseConfig.status || responseConfig.status < 200 || responseConfig.status > 599)) { | ||
throw new TypeError(`Invalid status ${responseConfig.status} passed on response object. | ||
To respond with a JSON object that has status as a property assign the object to body | ||
e.g. {"body": {"status: "registered"}}`); | ||
} | ||
opts.status = responseConfig.status || 200; | ||
@@ -300,0 +305,0 @@ opts.statusText = statusTextMap['' + opts.status]; |
@@ -778,10 +778,19 @@ 'use strict'; | ||
it('should accept object respones when passing options', () => { | ||
expect(() => { | ||
fetchMock.mock('http://foo.com', { foo: 'bar' }, { method: 'GET' }) | ||
}).to.not.throw(); | ||
fetchMock.restore(); | ||
}) | ||
it('should expect valid statuses', () => { | ||
fetchMock.mock('http://foo.com', { status: 'not number' }) | ||
expect(() => fetch('http://foo.com')) | ||
.to.throw(`Invalid status not number passed on response object. | ||
To respond with a JSON object that has status as a property assign the object to body | ||
e.g. {"body": {"status: "registered"}}`); | ||
fetchMock.restore(); | ||
}) | ||
}) | ||
}); | ||
} |
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
93287
2294
72