From a2d4d6b119b2f0cf4f63920b4994b468fabf6187 Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Thu, 8 Oct 2020 12:15:43 +0200 Subject: [PATCH 1/2] finished --- .../__snapshots__/render.test.js.snap | 30 +++++ src/__tests__/render.test.js | 103 ++++++++++++++++++ src/helpers/getByAPI.js | 77 +++++++++++++ typings/index.d.ts | 1 + 4 files changed, 211 insertions(+) diff --git a/src/__tests__/__snapshots__/render.test.js.snap b/src/__tests__/__snapshots__/render.test.js.snap index 55a88ffb7..5fb44fae6 100644 --- a/src/__tests__/__snapshots__/render.test.js.snap +++ b/src/__tests__/__snapshots__/render.test.js.snap @@ -56,6 +56,12 @@ exports[`debug 1`] = ` > Second Text + + multiple + + + multiple + 0 @@ -118,6 +124,12 @@ exports[`debug changing component: bananaFresh button message should now be "fre > Second Text + + multiple + + + multiple + 0 @@ -166,6 +178,12 @@ exports[`debug: shallow 1`] = ` > Second Text + + multiple + + + multiple + 0 @@ -216,6 +234,12 @@ exports[`debug: shallow with message 1`] = ` > Second Text + + multiple + + + multiple + 0 @@ -280,6 +304,12 @@ exports[`debug: with message 1`] = ` > Second Text + + multiple + + + multiple + 0 diff --git a/src/__tests__/render.test.js b/src/__tests__/render.test.js index d7d4a0b2e..b471762a6 100644 --- a/src/__tests__/render.test.js +++ b/src/__tests__/render.test.js @@ -1,6 +1,7 @@ // @flow import React from 'react'; import { + Button, View, Text, TextInput, @@ -73,6 +74,8 @@ class Banana extends React.Component { First Text Second Text + multiple + multiple {test} ); @@ -133,6 +136,9 @@ test('getByText, queryByText', () => { expect(sameButton.props.children).toBe('not fresh'); expect(() => getByText('InExistent')).toThrow('No instances found'); + expect(() => getByText('multiple')).toThrow( + 'Expected 1 but found 2 instances' + ); const zeroText = getByText('0'); @@ -165,6 +171,103 @@ test('getByText, queryByText with children as Array', () => { ]); }); +const MyText = (props) => ; + +const Component = () => { + return ( + +