Skip to content

Commit

Permalink
test: fix mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Oct 14, 2019
1 parent f2fab96 commit 8762a87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/rulesets/__tests__/reader.jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Rulesets reader', () => {

afterEach(() => {
nock.cleanAll();
nock.enableNetConnect();
});

it('given flat, valid ruleset file should return rules', async () => {
Expand Down Expand Up @@ -598,7 +599,6 @@ describe('Rulesets reader', () => {
});

it('is able to load the whole ruleset from static file', async () => {
nock.cleanAll();
nock.disableNetConnect();

const readFileSpy = jest.spyOn(fs, 'readFile');
Expand Down
14 changes: 5 additions & 9 deletions src/rulesets/__tests__/reader.karma.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import { FetchMockSandbox } from 'fetch-mock';
import { Spectral } from '../../spectral';
import { readRuleset } from '../reader';

describe('Rulesets reader', () => {
let fetchMock: FetchMockSandbox;

beforeEach(() => {
fetchMock = require('fetch-mock').sandbox();
window.fetch = fetchMock;
});
declare const fetch: FetchMockSandbox;

describe('Rulesets reader', () => {
afterEach(() => {
window.fetch = fetch;
Spectral.registerStaticAssets({});
});

it('is able to load the whole ruleset from static file', async () => {
fetchMock.get('https://unpkg.com/@stoplight/spectral/rulesets/oas/index.json', {
fetch.resetBehavior();
fetch.get('https://unpkg.com/@stoplight/spectral/rulesets/oas/index.json', {
status: 404,
body: {},
});
Expand Down

0 comments on commit 8762a87

Please sign in to comment.