Skip to content

Commit

Permalink
Manually mock request
Browse files Browse the repository at this point in the history
  • Loading branch information
neonowy committed Oct 31, 2017
1 parent c3b0d65 commit 88c19ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions __tests__/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Config from '../../src/config.js';
import path from 'path';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
// the mocked requests have stripped metadata, don't use it in the following tests
jest.unmock('request');

const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'info');

Expand Down Expand Up @@ -48,6 +46,11 @@ const expectedKeys = [
// yarn now ships as built, single JS files so it has no dependencies and no scripts
const unexpectedKeys = ['dependencies', 'devDependencies', 'scripts'];

beforeEach(() => {
// the mocked requests have stripped metadata, don't use it in the following tests
jest.unmock('request');
});

test.concurrent('without arguments and in directory containing a valid package file', (): Promise<void> => {
return runInfo([], {}, 'local', (config, output): ?Promise<void> => {
const actualKeys = Object.keys(output);
Expand Down Expand Up @@ -89,6 +92,8 @@ test.concurrent('with two arguments and second argument "readme" shows readme st
});

test.concurrent('with two arguments and second argument "version" shows `latest` version', (): Promise<void> => {
jest.mock('../__mocks__/request.js');

return runInfo(['ui-select', 'version'], {}, '', (config, output): ?Promise<void> => {
expect(output).toEqual('0.19.8');
});
Expand Down

0 comments on commit 88c19ad

Please sign in to comment.