From f3adb63af5d8172ae95cbff6761c76a6262a90e8 Mon Sep 17 00:00:00 2001 From: Rayat Rahman Date: Tue, 17 Aug 2021 19:29:44 -0700 Subject: [PATCH] chore(types): Convert src/query-helpers to TS --- src/__tests__/get-user-code-frame.js | 28 +- src/__tests__/role.js | 552 +++++++++++++-------------- src/__tests__/suggestions.js | 70 ++-- src/queries/label-text.ts | 3 - src/queries/placeholder-text.ts | 3 - src/queries/test-id.ts | 3 - src/query-helpers.js | 192 ---------- src/query-helpers.ts | 310 +++++++++++++++ types/query-helpers.d.ts | 19 +- 9 files changed, 649 insertions(+), 531 deletions(-) delete mode 100644 src/query-helpers.js create mode 100644 src/query-helpers.ts diff --git a/src/__tests__/get-user-code-frame.js b/src/__tests__/get-user-code-frame.js index 8d2bd058..6befcc78 100644 --- a/src/__tests__/get-user-code-frame.js +++ b/src/__tests__/get-user-code-frame.js @@ -39,13 +39,13 @@ test('it returns only user code frame when code frames from node_modules are fir const userTrace = getUserCodeFrame(stack) expect(userTrace).toMatchInlineSnapshot(` - /sample-error/error-example.js:7:14 - 5 | document.createTextNode('Hello world') - 6 | ) - > 7 | screen.debug() - | ^ - - `) +"/sample-error/error-example.js:7:14 + 5 | document.createTextNode('Hello world') + 6 | ) +> 7 | screen.debug() + | ^ +" +`) }) test('it returns only user code frame when node code frames are present afterwards', () => { @@ -59,13 +59,13 @@ test('it returns only user code frame when node code frames are present afterwar const userTrace = getUserCodeFrame() expect(userTrace).toMatchInlineSnapshot(` - /sample-error/error-example.js:7:14 - 5 | document.createTextNode('Hello world') - 6 | ) - > 7 | screen.debug() - | ^ - - `) +"/sample-error/error-example.js:7:14 + 5 | document.createTextNode('Hello world') + 6 | ) +> 7 | screen.debug() + | ^ +" +`) }) test("it returns empty string if file from code frame can't be read", () => { diff --git a/src/__tests__/role.js b/src/__tests__/role.js index c7dc70c5..a63043e3 100644 --- a/src/__tests__/role.js +++ b/src/__tests__/role.js @@ -5,100 +5,100 @@ import {render, renderIntoDocument} from './helpers/test-utils' test('by default logs accessible roles when it fails', () => { const {getByRole} = render(`

Hi

`) expect(() => getByRole('article')).toThrowErrorMatchingInlineSnapshot(` -"Unable to find an accessible element with the role "article" + "Unable to find an accessible element with the role "article" -Here are the accessible roles: + Here are the accessible roles: - heading: + heading: - Name "Hi": -

+ Name "Hi": +

- -------------------------------------------------- + -------------------------------------------------- -Ignored nodes: comments,