Skip to content

Commit

Permalink
each
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 20, 2020
1 parent 348f375 commit a7fac13
Showing 1 changed file with 39 additions and 69 deletions.
108 changes: 39 additions & 69 deletions packages/babel-jest/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,81 +49,51 @@ test('Returns source string with inline maps when no transformOptions is passed'
expect(JSON.stringify(result.map!.sourcesContent)).toMatch('customMultiply');
});

describe('caller option', () => {
test('correctly merges from defaults and options', () => {
describe('caller option correctly merges from defaults and options', () => {
test.each([
[
{
supportsDynamicImport: true,
supportsStaticESM: true,
},
{
supportsDynamicImport: true,
supportsStaticESM: true,
},
],
[
{
supportsDynamicImport: false,
supportsStaticESM: false,
},
{
supportsDynamicImport: false,
supportsStaticESM: false,
},
],
[
{supportsStaticESM: false},
{
supportsDynamicImport: false,
supportsStaticESM: false,
},
],
[
{supportsDynamicImport: true},
{
supportsDynamicImport: true,
supportsStaticESM: false,
},
],
])('%j -> %j', (input, output) => {
babelJest.process(sourceString, 'dummy_path.js', makeProjectConfig(), {
instrument: false,
// @ts-ignore
supportsDynamicImport: true,
supportsStaticESM: true,
...input,
});

expect(loadPartialConfig).toHaveBeenCalledTimes(1);
expect(loadPartialConfig).toHaveBeenCalledWith(
expect.objectContaining({
caller: {
name: 'babel-jest',
supportsDynamicImport: true,
supportsStaticESM: true,
},
}),
);

loadPartialConfig.mockClear();

babelJest.process(sourceString, 'dummy_path.js', makeProjectConfig(), {
instrument: false,
// @ts-ignore
supportsDynamicImport: false,
supportsStaticESM: false,
});

expect(loadPartialConfig).toHaveBeenCalledTimes(1);
expect(loadPartialConfig).toHaveBeenCalledWith(
expect.objectContaining({
caller: {
name: 'babel-jest',
supportsDynamicImport: false,
supportsStaticESM: false,
},
}),
);

loadPartialConfig.mockClear();

babelJest.process(sourceString, 'dummy_path.js', makeProjectConfig(), {
instrument: false,
supportsStaticESM: false,
});

expect(loadPartialConfig).toHaveBeenCalledTimes(1);
expect(loadPartialConfig).toHaveBeenCalledWith(
expect.objectContaining({
caller: {
name: 'babel-jest',
supportsDynamicImport: false,
supportsStaticESM: false,
},
}),
);

loadPartialConfig.mockClear();

babelJest.process(sourceString, 'dummy_path.js', makeProjectConfig(), {
instrument: false,
// @ts-ignore
supportsDynamicImport: true,
});

expect(loadPartialConfig).toHaveBeenCalledTimes(1);
expect(loadPartialConfig).toHaveBeenCalledWith(
expect.objectContaining({
caller: {
name: 'babel-jest',
supportsDynamicImport: true,
supportsStaticESM: false,
},
}),
expect.objectContaining({caller: {name: 'babel-jest', ...output}}),
);
});
});

0 comments on commit a7fac13

Please sign in to comment.