diff --git a/package.json b/package.json index 9773739435..008d0ebe4d 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "eslint-config-airbnb-base": "^8.0.0", "eslint-plugin-import": "^1.16.0", "eslint-plugin-mocha": "^4.8.0", - "fetch-mock": "^5.1.0", + "fetch-mock": "^6.0.0", "generate-changelog": "^1.0.2", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", @@ -128,7 +128,7 @@ "lodash.template": "^4.4.0", "log-symbols": "^2.0.0", "mime-types": "^2.1.17", - "node-fetch": "^1.6.3", + "node-fetch": "^2.0.0", "node-gyp": "^3.4.0", "nugget": "^2.0.1", "opn": "^5.0.0", diff --git a/test/slow/install_spec_slow.js b/test/slow/install_spec_slow.js index 12e44c1935..18cdee2552 100644 --- a/test/slow/install_spec_slow.js +++ b/test/slow/install_spec_slow.js @@ -1,5 +1,5 @@ import chai, { expect } from 'chai'; -import fetchMock from 'fetch-mock'; +import fetchMock from 'fetch-mock/es5/server'; import chaiAsPromised from 'chai-as-promised'; import proxyquire from 'proxyquire'; import sinon from 'sinon'; @@ -10,16 +10,18 @@ describe('install', () => { let install; let nuggetSpy; let mockInquirer; + let fetch; const mockInstaller = () => Promise.resolve(); beforeEach(() => { + fetch = fetchMock.sandbox(); nuggetSpy = sinon.stub(); mockInquirer = { createPromptModule: sinon.spy(() => sinon.spy(() => Promise.resolve({ assetID: 1 }))), }; install = proxyquire.noCallThru().load('../../src/api/install', { - 'node-fetch': fetchMock.fetchMock, + 'node-fetch': fetch, nugget: (...args) => { nuggetSpy(...args); args[args.length - 1](); @@ -34,7 +36,7 @@ describe('install', () => { }); afterEach(() => { - fetchMock.restore(); + fetch.restore(); }); it('should throw an error when a repo name is not given', async () => { @@ -46,7 +48,7 @@ describe('install', () => { }); it('should throw an error if the fetch fails', async () => { - fetchMock.get('*', { + fetch.get('*', { throws: new Error('it broke'), }); await expect(install({ repo: 'a/b', interactive: false })).to.eventually.be.rejectedWith( @@ -55,7 +57,7 @@ describe('install', () => { }); it('should throw an error if we can\'t find the repo', async () => { - fetchMock.get('*', { + fetch.get('*', { message: 'Not Found', }); await expect(install({ repo: 'b/c', interactive: false })).to.eventually.be.rejectedWith( @@ -64,7 +66,7 @@ describe('install', () => { }); it('should throw an error if the API does not return a release array', async () => { - fetchMock.get('*', { + fetch.get('*', { lolz: 'this aint no array', }); await expect(install({ repo: 'c/d', interactive: false })).to.eventually.be.rejectedWith( @@ -73,7 +75,7 @@ describe('install', () => { }); it('should throw an error if the latest release has no assets', async () => { - fetchMock.get('*', [ + fetch.get('*', [ { tag_name: 'v1.0.0' }, { tag_name: '0.3.0' }, { tag_name: 'v1.2.0' }, @@ -85,7 +87,7 @@ describe('install', () => { }); it('should throw an error if there are no release compatable with the current platform', async () => { - fetchMock.get('*', [ + fetch.get('*', [ { tag_name: '1.0.0', assets: [ @@ -103,8 +105,8 @@ describe('install', () => { // eslint-disable-next-line no-nested-ternary const compatSuffix = process.platform === 'darwin' ? 'dmg' : (process.platform === 'win32' ? 'exe' : 'deb'); - it('should download a release if there is a single compatable asset', async () => { - fetchMock.get('*', [ + it('should download a release if there is a single compatible asset', async () => { + fetch.get('*', [ { tag_name: '1.0.0', assets: [ @@ -122,7 +124,7 @@ describe('install', () => { }); it('should throw an error if there is more than compatable asset with no chooseAsset method', async () => { - fetchMock.get('*', [ + fetch.get('*', [ { tag_name: '1.0.0', assets: [ @@ -144,7 +146,7 @@ describe('install', () => { it('should provide compatable assets to chooseAsset if more than one exists', async () => { const chooseAsset = sinon.spy(async assets => assets[0]); - fetchMock.get('*', [ + fetch.get('*', [ { tag_name: '1.0.0', assets: [ @@ -166,8 +168,7 @@ describe('install', () => { }); it('should prompt the user to choose an asset if in interactive mode and more than one exists', async () => { -// mockInquirer - fetchMock.get('*', [ + fetch.get('*', [ { tag_name: '1.0.0', assets: [