From 61623ddee81a1378b1c4a22188cabc113a31afdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 4 Oct 2018 09:17:15 +0200 Subject: [PATCH] simplify example --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 093e1020..59ef63a3 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,16 @@ This library is a replacement for [Enzyme](http://airbnb.io/enzyme/). import { render } from 'react-native-testing-library'; import { QuestionsBoard } from '../QuestionsBoard'; -function setAnswer(getAllByName, index, answer) { - getAllByName('Question')[index].props.onChangeText(answer); +function setAnswer(question, answer) { + question.props.onChangeText(answer); } test('should verify two questions', () => { const { getAllByName, getByText } = render(); + const allQuestions = getAllByName('Question'); - setAnswer(getAllByName, 0, 'a1'); - setAnswer(getAllByName, 1, 'a2'); + setAnswer(allQuestions[0], 'a1'); + setAnswer(allQuestions[1], 'a2'); getByText('submit').props.onPress();