From 5f6eac4f85226c2aafbec34a8d723dc24cc2b66d Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 19 Feb 2020 21:11:06 +0100 Subject: [PATCH] each --- packages/babel-jest/src/__tests__/index.ts | 108 ++++++++------------- 1 file changed, 39 insertions(+), 69 deletions(-) diff --git a/packages/babel-jest/src/__tests__/index.ts b/packages/babel-jest/src/__tests__/index.ts index aa1702156285..7bbc4f7c84d1 100644 --- a/packages/babel-jest/src/__tests__/index.ts +++ b/packages/babel-jest/src/__tests__/index.ts @@ -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}}), ); }); });