Skip to content

Commit

Permalink
Tests: Refactor tests for normalize module from jest-config
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Feb 12, 2018
1 parent de50584 commit 757bc3b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ describe('preset', () => {
}
return '/node_modules/' + name;
});
jest.mock(
jest.doMock(
'/node_modules/react-native/jest-preset.json',
() => ({
moduleNameMapper: {b: 'b'},
Expand All @@ -888,7 +888,7 @@ describe('preset', () => {
});

afterEach(() => {
jest.unmock('/node_modules/react-native/jest-preset.json');
jest.dontMock('/node_modules/react-native/jest-preset.json');
});

test('throws when preset not found', () => {
Expand All @@ -904,7 +904,7 @@ describe('preset', () => {
});

test('throws when preset is invalid', () => {
jest.mock('/node_modules/react-native/jest-preset.json', () =>
jest.doMock('/node_modules/react-native/jest-preset.json', () =>
require.requireActual('./jest-preset.json'),
);

Expand Down Expand Up @@ -983,14 +983,14 @@ describe('preset', () => {
});

test('merges with options and transform preset is overridden by options', () => {
// Object initializer not used for properties as a workaround for
// sort-keys eslint rule while specifying properties in
// non-alphabetical order for a better test
const transform = {};
transform.e = 'ee';
transform.b = 'bb';
transform.c = 'cc';
transform.a = 'aa';
/* eslint-disable sort-keys */
const transform = {
e: 'ee',
b: 'bb',
c: 'cc',
a: 'aa',
};
/* eslint-disable sort-keys */
const {options} = normalize(
{
preset: 'react-native',
Expand Down Expand Up @@ -1019,7 +1019,7 @@ describe('preset without setupFiles', () => {
});

beforeAll(() => {
jest.mock(
jest.doMock(
'/node_modules/react-foo/jest-preset.json',
() => {
return {
Expand All @@ -1031,6 +1031,10 @@ describe('preset without setupFiles', () => {
);
});

afterAll(() => {
jest.dontMock('/node_modules/react-foo/jest-preset.json');
});

it('should normalize setupFiles correctly', () => {
const {options} = normalize(
{
Expand Down

0 comments on commit 757bc3b

Please sign in to comment.