Skip to content

Commit

Permalink
chore(generic): upgrade node-fetch to 2.0.0 and fetch-mock to 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Feb 14, 2018
1 parent bc7a148 commit 42abee3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
29 changes: 15 additions & 14 deletions test/slow/install_spec_slow.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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]();
Expand All @@ -34,7 +36,7 @@ describe('install', () => {
});

afterEach(() => {
fetchMock.restore();
fetch.restore();
});

it('should throw an error when a repo name is not given', async () => {
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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' },
Expand All @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand Down

0 comments on commit 42abee3

Please sign in to comment.