From b64b6428cb83829d471b353546e877d3de72f4a4 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Thu, 1 Aug 2019 08:37:04 +0100 Subject: [PATCH] Add test for single column heading with text elsewhere in template string --- .../jest-each/src/__tests__/template.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/jest-each/src/__tests__/template.test.ts b/packages/jest-each/src/__tests__/template.test.ts index 417344e4f9a3..04ae8177b412 100644 --- a/packages/jest-each/src/__tests__/template.test.ts +++ b/packages/jest-each/src/__tests__/template.test.ts @@ -142,6 +142,27 @@ describe('jest-each', () => { ); }); + test('does not throw error when there is only one column with additional words in template after heading', () => { + const globalTestMocks = getGlobalTestMocks(); + const eachObject = each.withGlobal(globalTestMocks)` + a + hello world + ${1} + `; + const testFunction = get(eachObject, keyPath); + const testCallBack = jest.fn(); + testFunction('test title $a', testCallBack); + + const globalMock = get(globalTestMocks, keyPath); + + expect(globalMock).toHaveBeenCalledTimes(1); + expect(globalMock).toHaveBeenCalledWith( + 'test title 1', + expectFunction, + undefined, + ); + }); + test('throws error when there are no arguments for given headings', () => { const globalTestMocks = getGlobalTestMocks(); const eachObject = each.withGlobal(globalTestMocks)`