From 652bad87c4ad0c1bc02fb534895cbfa973cc5ab5 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Fri, 17 Feb 2023 19:38:37 +0200 Subject: [PATCH 1/4] test: add missing test for suggestions --- src/__tests__/suggestions.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/__tests__/suggestions.js b/src/__tests__/suggestions.js index 08ce2f7c..4839d263 100644 --- a/src/__tests__/suggestions.js +++ b/src/__tests__/suggestions.js @@ -103,6 +103,16 @@ test('should not suggest when suggest is turned off for a query', () => { ).not.toThrowError() }) +test('should suggest when suggest is turned on for a specific query but disabled in config', () => { + configure({throwSuggestions: false}) + renderIntoDocument(` + + `) + + expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError() + configure({throwSuggestions: true}) +}) + test('should suggest getByRole when used with getBy', () => { renderIntoDocument(``) From 6d62cc67cdefe18b0b5e636ecc88aa7e463a40c4 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Fri, 17 Feb 2023 22:40:05 +0200 Subject: [PATCH 2/4] fix: cleanup in afterEach --- src/__tests__/suggestions.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/__tests__/suggestions.js b/src/__tests__/suggestions.js index 4839d263..03bf9103 100644 --- a/src/__tests__/suggestions.js +++ b/src/__tests__/suggestions.js @@ -7,7 +7,7 @@ beforeAll(() => { }) afterEach(() => { - configure({testIdAttribute: 'data-testid'}) + configure({testIdAttribute: 'data-testid', throwSuggestions: true}) console.warn.mockClear() }) @@ -110,7 +110,6 @@ test('should suggest when suggest is turned on for a specific query but disabled `) expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError() - configure({throwSuggestions: true}) }) test('should suggest getByRole when used with getBy', () => { From ab0f71a88db1b454fa8252f0949348035d37fc1c Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 8 Mar 2023 12:01:44 +0100 Subject: [PATCH 3/4] Check we actually suggest --- src/__tests__/suggestions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/suggestions.js b/src/__tests__/suggestions.js index 03bf9103..a53c28eb 100644 --- a/src/__tests__/suggestions.js +++ b/src/__tests__/suggestions.js @@ -109,7 +109,7 @@ test('should suggest when suggest is turned on for a specific query but disabled `) - expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError() + expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError("try this:\ngetByRole('button', { name: /submit/i })") }) test('should suggest getByRole when used with getBy', () => { From f48356c55e4629a70015daa38b492730396dadd4 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 8 Mar 2023 12:14:18 +0100 Subject: [PATCH 4/4] TODO: reword+fixup --- src/__tests__/suggestions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/__tests__/suggestions.js b/src/__tests__/suggestions.js index a53c28eb..6c723a65 100644 --- a/src/__tests__/suggestions.js +++ b/src/__tests__/suggestions.js @@ -109,7 +109,9 @@ test('should suggest when suggest is turned on for a specific query but disabled `) - expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError("try this:\ngetByRole('button', { name: /submit/i })") + expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError( + "try this:\ngetByRole('button', { name: /submit/i })", + ) }) test('should suggest getByRole when used with getBy', () => {