Socket
Socket
Sign inDemoInstall

fetch-mock

Package Overview
Dependencies
Maintainers
1
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-mock - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

es5/status-text.js

79

es5/client-browserified.js

@@ -5,2 +5,3 @@ (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 FetchMock = require('./fetch-mock');
var statusTextMap = require('./status-text');

@@ -11,6 +12,7 @@ module.exports = new FetchMock({

Response: window.Response,
Headers: window.Headers
Headers: window.Headers,
statusTextMap: statusTextMap
});
},{"./fetch-mock":2}],2:[function(require,module,exports){
},{"./fetch-mock":2,"./status-text":3}],2:[function(require,module,exports){
'use strict';

@@ -29,2 +31,3 @@

var theGlobal = undefined;
var statusTextMap = undefined;

@@ -62,2 +65,3 @@ /**

opts.status = responseConfig.status || 200;
opts.statusText = statusTextMap['' + opts.status];
// The ternary operator is to cope with new Headers(undefined) throwing in Chrome

@@ -193,2 +197,3 @@ // https://code.google.com/p/chromium/issues/detail?id=335871

theGlobal = opts.theGlobal;
statusTextMap = opts.statusTextMap;
this.routes = [];

@@ -466,3 +471,73 @@ this._calls = {};

},{}],3:[function(require,module,exports){
'use strict';
var statusTextMap = {
'100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'200': 'OK',
'201': 'Created',
'202': 'Accepted',
'203': 'Non-Authoritative Information',
'204': 'No Content',
'205': 'Reset Content',
'206': 'Partial Content',
'207': 'Multi-Status',
'208': 'Already Reported',
'226': 'IM Used',
'300': 'Multiple Choices',
'301': 'Moved Permanently',
'302': 'Found',
'303': 'See Other',
'304': 'Not Modified',
'305': 'Use Proxy',
'307': 'Temporary Redirect',
'308': 'Permanent Redirect',
'400': 'Bad Request',
'401': 'Unauthorized',
'402': 'Payment Required',
'403': 'Forbidden',
'404': 'Not Found',
'405': 'Method Not Allowed',
'406': 'Not Acceptable',
'407': 'Proxy Authentication Required',
'408': 'Request Timeout',
'409': 'Conflict',
'410': 'Gone',
'411': 'Length Required',
'412': 'Precondition Failed',
'413': 'Payload Too Large',
'414': 'URI Too Long',
'415': 'Unsupported Media Type',
'416': 'Range Not Satisfiable',
'417': 'Expectation Failed',
'418': 'I\'m a teapot',
'421': 'Misdirected Request',
'422': 'Unprocessable Entity',
'423': 'Locked',
'424': 'Failed Dependency',
'425': 'Unordered Collection',
'426': 'Upgrade Required',
'428': 'Precondition Required',
'429': 'Too Many Requests',
'431': 'Request Header Fields Too Large',
'451': 'Unavailable For Legal Reasons',
'500': 'Internal Server Error',
'501': 'Not Implemented',
'502': 'Bad Gateway',
'503': 'Service Unavailable',
'504': 'Gateway Timeout',
'505': 'HTTP Version Not Supported',
'506': 'Variant Also Negotiates',
'507': 'Insufficient Storage',
'508': 'Loop Detected',
'509': 'Bandwidth Limit Exceeded',
'510': 'Not Extended',
'511': 'Network Authentication Required'
};
module.exports = statusTextMap;
},{}]},{},[1])(1)
});

4

es5/client.js
'use strict';
var FetchMock = require('./fetch-mock');
var statusTextMap = require('./status-text');

@@ -9,3 +10,4 @@ module.exports = new FetchMock({

Response: window.Response,
Headers: window.Headers
Headers: window.Headers,
statusTextMap: statusTextMap
});

@@ -14,2 +14,3 @@ 'use strict';

var theGlobal = undefined;
var statusTextMap = undefined;

@@ -47,2 +48,3 @@ /**

opts.status = responseConfig.status || 200;
opts.statusText = statusTextMap['' + opts.status];
// The ternary operator is to cope with new Headers(undefined) throwing in Chrome

@@ -178,2 +180,3 @@ // https://code.google.com/p/chromium/issues/detail?id=335871

theGlobal = opts.theGlobal;
statusTextMap = opts.statusTextMap;
this.routes = [];

@@ -180,0 +183,0 @@ this._calls = {};

@@ -9,2 +9,3 @@ 'use strict';

var FetchMock = require('./fetch-mock');
var http = require('http');

@@ -16,3 +17,4 @@ module.exports = new FetchMock({

Headers: Headers,
stream: stream
stream: stream,
statusTextMap: http.STATUS_CODES
});
{
"name": "fetch-mock",
"version": "4.2.0",
"version": "4.3.0",
"description": "Mock http requests made using fetch (or isomorphic-fetch)",

@@ -5,0 +5,0 @@ "main": "src/server.js",

'use strict';
const FetchMock = require('./fetch-mock');
const statusTextMap = require('./status-text');

@@ -9,3 +10,4 @@ module.exports = new FetchMock({

Response: window.Response,
Headers: window.Headers
Headers: window.Headers,
statusTextMap: statusTextMap
});

@@ -8,2 +8,3 @@ 'use strict';

let theGlobal;
let statusTextMap;

@@ -41,2 +42,3 @@ /**

opts.status = responseConfig.status || 200;
opts.statusText = statusTextMap['' + opts.status];
// The ternary operator is to cope with new Headers(undefined) throwing in Chrome

@@ -161,2 +163,3 @@ // https://code.google.com/p/chromium/issues/detail?id=335871

theGlobal = opts.theGlobal;
statusTextMap = opts.statusTextMap;
this.routes = [];

@@ -163,0 +166,0 @@ this._calls = {};

@@ -8,2 +8,3 @@ 'use strict';

const FetchMock = require('./fetch-mock');
const http = require('http');

@@ -15,3 +16,4 @@ module.exports = new FetchMock({

Headers: Headers,
stream: stream
stream: stream,
statusTextMap: http.STATUS_CODES
});

@@ -547,2 +547,3 @@ 'use strict';

expect(res.status).to.equal(300);
expect(res.statusText).to.equal('Multiple Choices');
done();

@@ -552,3 +553,3 @@ });

it('respond with a string', function (done) {
it('respond with a string', function () {
fetchMock.mock({

@@ -561,13 +562,14 @@ routes: {

});
fetch('http://it.at.there/')
return fetch('http://it.at.there/')
.then(function (res) {
expect(res.status).to.equal(200);
res.text().then(function (text) {
expect(text).to.equal('a string');
done();
});
expect(res.statusText).to.equal('OK');
return res.text()
})
.then(function (text) {
expect(text).to.equal('a string');
});
});
it('respond with a json', function (done) {
it('respond with a json', function () {
fetchMock.mock({

@@ -580,13 +582,14 @@ routes: {

});
fetch('http://it.at.there/')
return fetch('http://it.at.there/')
.then(function (res) {
expect(res.status).to.equal(200);
res.json().then(function (json) {
expect(json).to.eql({an: 'object'});
done();
});
expect(res.statusText).to.equal('OK');
return res.json();
})
.then(function (json) {
expect(json).to.eql({an: 'object'});
});
});
it('respond with a status', function (done) {
it('respond with a status', function () {
fetchMock.mock({

@@ -599,6 +602,6 @@ routes: {

});
fetch('http://it.at.there/')
return fetch('http://it.at.there/')
.then(function (res) {
expect(res.status).to.equal(404);
done();
expect(res.statusText).to.equal('Not Found');
});

@@ -605,0 +608,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc