From 3f6454589cb47acc7c401e33c437ee5df9f6bb23 Mon Sep 17 00:00:00 2001
From: Matan Borenkraout <Matanbobi@gmail.com>
Date: Wed, 8 Mar 2023 14:17:52 +0200
Subject: [PATCH] test: add missing test for suggestions (#1215)

* test: add missing test for suggestions

* fix: cleanup in afterEach

* Check we actually suggest

* TODO: reword+fixup

---------

Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
---
 src/__tests__/suggestions.js | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/__tests__/suggestions.js b/src/__tests__/suggestions.js
index 08ce2f7c..6c723a65 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()
 })
 
@@ -103,6 +103,17 @@ 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(`
+  <button data-testid="foo">submit</button>
+  <button data-testid="foot">another</button>`)
+
+  expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError(
+    "try this:\ngetByRole('button', { name: /submit/i })",
+  )
+})
+
 test('should suggest getByRole when used with getBy', () => {
   renderIntoDocument(`<button data-testid="foo">submit</button>`)