From 90a47329966ffb4932bf97cd38dc2105cfeee881 Mon Sep 17 00:00:00 2001 From: Mehdi <40258654+seven-deuce@users.noreply.github.com> Date: Wed, 22 May 2019 09:08:44 +0400 Subject: [PATCH 1/2] addons-shallow-renderer.md --- content/docs/addons-shallow-renderer.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content/docs/addons-shallow-renderer.md b/content/docs/addons-shallow-renderer.md index 7b7f29f3c..7302f6c02 100644 --- a/content/docs/addons-shallow-renderer.md +++ b/content/docs/addons-shallow-renderer.md @@ -13,11 +13,11 @@ import ShallowRenderer from 'react-test-renderer/shallow'; // ES6 var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 with npm ``` -## Overview {#overview} +## مرور کلی {#overview} -When writing unit tests for React, shallow rendering can be helpful. Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM. +هنگام نوشتن یونیت تست برای ری‌اکت، رندر کردن سطحی (shallow rendering) می‌تواند مفید باشد. هنگام رندر کردن سطحی، این امکان را پیدا می‌کنید که یک کامپوننت را فقط در یک سطح رندر کنید، این بدین معناست که دیگر نگران کامپوننت های فرزندش نخواهید بود، چون آنها رندر نخواهند شد. پس نتایج رندر مربوط به همان کامپوننت را خواهید دید. برای انجام این کار، نیازی به DOM نخواهد بود. -For example, if you have the following component: +به طور مثال اگر کامپوننت زیر را داشته باشید: ```javascript function MyComponent() { @@ -30,7 +30,7 @@ function MyComponent() { } ``` -Then you can assert: +آنگاه می‌توانید تست کنید: ```javascript import ShallowRenderer from 'react-test-renderer/shallow'; @@ -47,22 +47,22 @@ expect(result.props.children).toEqual([ ]); ``` -Shallow testing currently has some limitations, namely not supporting refs. +رندر کردن سطحی، در حال حاضر محدودیت هایی دارد، من جمله اینکه از ref ها پشتیبانی نمی‌کند. -> Note: +> توجه: > -> We also recommend checking out Enzyme's [Shallow Rendering API](https://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality. +> توصیه می‌کنیم [Shallow Rendering API](https://airbnb.io/enzyme/docs/api/shallow.html) متعلق به Enzyme را ببینید که API سطح بالای مناسبتری را در اختیار شما قرار می‌دهد که همین کارکرد را دارد. -## Reference {#reference} +## مرجع {#reference} ### `shallowRenderer.render()` {#shallowrendererrender} -You can think of the shallowRenderer as a "place" to render the component you're testing, and from which you can extract the component's output. +این طور فرض کنید که shallowRenderer، " مکانی" است برای رندر کردن کامپوننت مورد نظر شما، که خروجی کامپوننت شما را نمایش خواهد داد. -`shallowRenderer.render()` is similar to [`ReactDOM.render()`](/docs/react-dom.html#render) but it doesn't require DOM and only renders a single level deep. This means you can test components isolated from how their children are implemented. +`shallowRenderer.render()` مشابه [`ReactDOM.render()`](/docs/react-dom.html#render) می‌باشد، اما نیازی به DOM ندارد و فقط در یک سطح رندر را انجام می‌دهد. به همین خاطر می‌توانید یک کامپوننت را در انزوا، و فارغ از کارکرد کامپوننت های فرزندنش اجرا کنید. ### `shallowRenderer.getRenderOutput()` {#shallowrenderergetrenderoutput} -After `shallowRenderer.render()` has been called, you can use `shallowRenderer.getRenderOutput()` to get the shallowly rendered output. +پس از آنکه `shallowRenderer.render()` فراخوانی شد، با استفاده از `shallowRenderer.getRenderOutput()` می‌توانید خروجی رندر سطحی را مشاهده کنید. -You can then begin to assert facts about the output. +سپس قادر خواهید بود تا نتایج خروجی را تست کنید. From e62afcb8ee3460b972a7a8da784bfb9795ab28d7 Mon Sep 17 00:00:00 2001 From: Mehdi <40258654+seven-deuce@users.noreply.github.com> Date: Fri, 24 May 2019 13:32:45 +0400 Subject: [PATCH 2/2] correction final --- content/docs/addons-shallow-renderer.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/addons-shallow-renderer.md b/content/docs/addons-shallow-renderer.md index 7302f6c02..f51221974 100644 --- a/content/docs/addons-shallow-renderer.md +++ b/content/docs/addons-shallow-renderer.md @@ -15,7 +15,7 @@ var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 with npm ## مرور کلی {#overview} -هنگام نوشتن یونیت تست برای ری‌اکت، رندر کردن سطحی (shallow rendering) می‌تواند مفید باشد. هنگام رندر کردن سطحی، این امکان را پیدا می‌کنید که یک کامپوننت را فقط در یک سطح رندر کنید، این بدین معناست که دیگر نگران کامپوننت های فرزندش نخواهید بود، چون آنها رندر نخواهند شد. پس نتایج رندر مربوط به همان کامپوننت را خواهید دید. برای انجام این کار، نیازی به DOM نخواهد بود. +هنگام نوشتن یونیت تست برای ری‌اکت، رندر کردن سطحی (shallow rendering) می‌تواند مفید باشد. هنگام رندر کردن سطحی، این امکان را پیدا می‌کنید که یک کامپوننت را فقط در یک سطح رندر کنید، این بدین معناست که دیگر نگران کامپوننت های فرزندش نخواهید بود، چون آنها رندر نخواهند شد. پس نتایج رندر مربوط به همان کامپوننت را می‌توانید تست کنید. برای انجام این کار، نیازی به DOM نخواهد بود. به طور مثال اگر کامپوننت زیر را داشته باشید: @@ -47,11 +47,11 @@ expect(result.props.children).toEqual([ ]); ``` -رندر کردن سطحی، در حال حاضر محدودیت هایی دارد، من جمله اینکه از ref ها پشتیبانی نمی‌کند. +رندر کردن سطحی، در حال حاضر محدودیت هایی دارد، از جمله اینکه از ref ها پشتیبانی نمی‌کند. > توجه: > -> توصیه می‌کنیم [Shallow Rendering API](https://airbnb.io/enzyme/docs/api/shallow.html) متعلق به Enzyme را ببینید که API سطح بالای مناسبتری را در اختیار شما قرار می‌دهد که همین کارکرد را دارد. +> توصیه می‌کنیم [Shallow Rendering API](https://airbnb.io/enzyme/docs/api/shallow.html) متعلق به Enzyme را ببینید که API سطح بالای مناسب‌تری را در اختیار شما قرار می‌دهد که همین کارکرد را دارد. ## مرجع {#reference}