Skip to content
Permalink
Browse files

chore(generic): upgrade node-fetch to 2.0.0 and fetch-mock to 6.0.0

  • Loading branch information
malept committed Feb 8, 2018
1 parent bc7a148 commit 42abee35a6e0eb81b9013abbf535e43bb4a1af2b
Showing with 17 additions and 16 deletions.
  1. +2 −2 package.json
  2. +15 −14 test/slow/install_spec_slow.js
@@ -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",
@@ -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: [

0 comments on commit 42abee3

Please sign in to comment.
You can’t perform that action at this time.