fetch-mock
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -137,3 +137,3 @@ 'use strict'; | ||
this.mockedContext = theGlobal; | ||
this.realFetch = theGlobal.fetch; | ||
this.realFetch = theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
} | ||
@@ -140,0 +140,0 @@ |
{ | ||
"name": "fetch-mock", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -5,0 +5,0 @@ "main": "src/server.js", |
@@ -123,3 +123,3 @@ 'use strict'; | ||
this.mockedContext = theGlobal; | ||
this.realFetch = theGlobal.fetch; | ||
this.realFetch = theGlobal.fetch && theGlobal.fetch.bind(theGlobal); | ||
} | ||
@@ -126,0 +126,0 @@ |
@@ -6,3 +6,16 @@ 'use strict'; | ||
var fetchMock = require('../src/client.js'); | ||
var expect = require('chai').expect; | ||
require('./spec')(fetchMock, window); | ||
describe('native fetch behaviour', function () { | ||
it('should not throw when passing unmatched calls through to native fetch', function () { | ||
fetchMock.mock(); | ||
expect(function () { | ||
fetch('http://www.example.com'); | ||
}).not.to.throw(); | ||
fetchMock.restore(); | ||
}); | ||
}) | ||
require('./spec')(fetchMock, window); | ||
'use strict'; | ||
var expect = require('chai').expect; | ||
var err = function (err) { | ||
console.log(error); | ||
} | ||
module.exports = function (fetchMock, theGlobal) { | ||
var fetchCalls = []; | ||
var expect = require('chai').expect; | ||
describe('fetch-mock', function () { | ||
// we can't use sinon to spy on fetch in these tests as fetch-mock | ||
// uses it internally and sinon doesn't allow spying on a previously | ||
// stubbed function, so just use this very basic stub | ||
var dummyFetch = theGlobal.fetch = fetchMock.realFetch = function () { | ||
fetchCalls.push([].slice.call(arguments)); | ||
return Promise.resolve(arguments); | ||
}; | ||
var fetchCalls = []; | ||
var dummyFetch = function () { | ||
fetchCalls.push([].slice.call(arguments)); | ||
return Promise.resolve(arguments); | ||
}; | ||
before(function () { | ||
theGlobal.fetch = fetchMock.realFetch = dummyFetch; | ||
}) | ||
var err = function (err) { | ||
console.log(error); | ||
} | ||
describe('fetch-mock', function () { | ||
afterEach(function () { | ||
@@ -24,0 +21,0 @@ fetchCalls = []; |
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
61255
1611
71