From b71339b4e0cbb49939049989cbf581be259bb709 Mon Sep 17 00:00:00 2001 From: Kolja Lampe Date: Fri, 10 Jun 2022 16:15:18 +0200 Subject: [PATCH] Fix typo (#5735) Co-authored-by: Dominic Saadi --- docs/docs/tutorial/chapter5/first-test.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/tutorial/chapter5/first-test.md b/docs/docs/tutorial/chapter5/first-test.md index efb11175973b..07f44e6a1218 100644 --- a/docs/docs/tutorial/chapter5/first-test.md +++ b/docs/docs/tutorial/chapter5/first-test.md @@ -59,7 +59,7 @@ test('Success renders successfully', async () => { -But the truncation length could change later, so how do we encapsulate that in our test? Or should we? The number of characters to truncate to is hardcoded in the `Article` component, which this component shouldn't really care about about: it should be up to the page that's presenting the article to determine much or how little to show (based on space concerns, design constraints, etc.) don't you think? Even if we refactored the `truncate()` function into a shared place and imported it into both `Article` and this test, the test will still be knowing too much about `Article`—why should it have detailed knowledge of the internals of `Article` and that it's making use of this `truncate()` function at all? It shouldn't! One theory of testing says that the thing you're testing should be a black box: you can't see inside of it, all you can test is what data comes out when you send certain data in. +But the truncation length could change later, so how do we encapsulate that in our test? Or should we? The number of characters to truncate to is hardcoded in the `Article` component, which this component shouldn't really care about: it should be up to the page that's presenting the article to determine much or how little to show (based on space concerns, design constraints, etc.) don't you think? Even if we refactored the `truncate()` function into a shared place and imported it into both `Article` and this test, the test will still be knowing too much about `Article`—why should it have detailed knowledge of the internals of `Article` and that it's making use of this `truncate()` function at all? It shouldn't! One theory of testing says that the thing you're testing should be a black box: you can't see inside of it, all you can test is what data comes out when you send certain data in. Let's compromise—by virtue of the fact that this functionality has a prop called "summary" we can guess that it's doing *something* to shorten the text. So what if we test three things that we can make reasonable assumptions about right now: