Skip to content

Commit 7804239

Browse files
committed
Done Translating-reference-test-renderer.md
1 parent c397e7d commit 7804239

File tree

1 file changed

+51
-53
lines changed

1 file changed

+51
-53
lines changed

content/docs/reference-test-renderer.md

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
**الاستيراد**
1010

1111
```javascript
1212
import TestRenderer from 'react-test-renderer'; // ES6
1313
const TestRenderer = require('react-test-renderer'); // ES5 with npm
1414
```
1515

16-
## Overview {#overview}
16+
## لمحة عامة {#overview}
1717

18-
This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.
18+
تُزوّدنا هذه الحزمة بمُصيِّر React يُمكِن استخدامه لتصيير مكوّنات React إلى كائنات JavaScript نقيّة بدون الاعتماد على DOM أو بيئة الهاتف المحمول الأصليّة.
1919

20-
Essentially, this package makes it easy to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a React DOM or React Native component without using a browser or [jsdom](https://github.com/tmpvar/jsdom).
20+
تُسهِّل هذه الحزمة بشكل أساسي من أخذ صورة حول التسلسل الهرمي للمكوّنات (مشابه لشجرة DOM) والتي يُصيّرها React DOM أو React Native بدون استخدام المتصفح أو [jsdom](https://github.com/tmpvar/jsdom).
2121

22-
Example:
22+
مثال:
2323

2424
```javascript
2525
import TestRenderer from 'react-test-renderer';
@@ -38,9 +38,9 @@ console.log(testRenderer.toJSON());
3838
// children: [ 'Facebook' ] }
3939
```
4040

41-
You can use Jest's snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn't changed: [Learn more about it](https://facebook.github.io/jest/blog/2016/07/27/jest-14.html).
41+
نستطيع استخدام ميزة الاختبار بالتقاط الصورة الموجودة في Jest لحفظ نسخة عن شجرة JSON بشكل تلقائي إلى ملف والتحقق في اختباراتك من أنّها لم تتغيّر. [تعلّم المزيد حول ذلك](https://facebook.github.io/jest/blog/2016/07/27/jest-14.html).
4242

43-
You can also traverse the output to find specific nodes and make assertions about them.
43+
بإمكانك أيضًا التنقل في الناتج لإيجاد عقد محددة:
4444

4545
```javascript
4646
import TestRenderer from 'react-test-renderer';
@@ -69,182 +69,180 @@ expect(testInstance.findByProps({className: "sub"}).children).toEqual(['Sub']);
6969

7070
### TestRenderer {#testrenderer}
7171

72-
* [`TestRenderer.create()`](#testrenderercreate)
72+
* [`()TestRenderer.create`](#testrenderercreate)
7373

7474
### TestRenderer instance {#testrenderer-instance}
7575

76-
* [`testRenderer.toJSON()`](#testrenderertojson)
77-
* [`testRenderer.toTree()`](#testrenderertotree)
78-
* [`testRenderer.update()`](#testrendererupdate)
79-
* [`testRenderer.unmount()`](#testrendererunmount)
80-
* [`testRenderer.getInstance()`](#testrenderergetinstance)
76+
* [`()testRenderer.toJSON`](#testrenderertojson)
77+
* [`()testRenderer.toTree`](#testrenderertotree)
78+
* [`()testRenderer.update`](#testrendererupdate)
79+
* [`()testRenderer.unmount`](#testrendererunmount)
80+
* [`()testRenderer.getInstance`](#testrenderergetinstance)
8181
* [`testRenderer.root`](#testrendererroot)
8282

8383
### TestInstance {#testinstance}
8484

85-
* [`testInstance.find()`](#testinstancefind)
86-
* [`testInstance.findByType()`](#testinstancefindbytype)
87-
* [`testInstance.findByProps()`](#testinstancefindbyprops)
88-
* [`testInstance.findAll()`](#testinstancefindall)
89-
* [`testInstance.findAllByType()`](#testinstancefindallbytype)
90-
* [`testInstance.findAllByProps()`](#testinstancefindallbyprops)
85+
* [`()testInstance.find`](#testinstancefind)
86+
* [`()testInstance.findByType`](#testinstancefindbytype)
87+
* [`()testInstance.findByProps`](#testinstancefindbyprops)
88+
* [`()testInstance.findAll`](#testinstancefindall)
89+
* [`()testInstance.findAllByType`](#testinstancefindallbytype)
90+
* [`()testInstance.findAllByProps`](#testinstancefindallbyprops)
9191
* [`testInstance.instance`](#testinstanceinstance)
9292
* [`testInstance.type`](#testinstancetype)
9393
* [`testInstance.props`](#testinstanceprops)
9494
* [`testInstance.parent`](#testinstanceparent)
9595
* [`testInstance.children`](#testinstancechildren)
9696

97-
## Reference {#reference}
97+
## مرجع {#reference}
9898

99-
### `TestRenderer.create()` {#testrenderercreate}
99+
### `()TestRenderer.create` {#testrenderercreate}
100100

101101
```javascript
102102
TestRenderer.create(element, options);
103103
```
104104

105-
Create a `TestRenderer` instance with the passed React element. It doesn't use the real DOM, but it still fully renders the component tree into memory so you can make assertions about it. The returned instance has the following methods and properties.
105+
إنشاء نسخة من `TestRenderer` مع عنصر React المُمرَّر. لا يستخدم هذا التابع DOM الحقيقي ولكنّه يُصيِّر بشكل كامل شجرة المكوّنات في الذاكرة. تملك النسخة المُعادة التوابع والخاصيّات التالية.
106106

107-
### `testRenderer.toJSON()` {#testrenderertojson}
107+
### `()testRenderer.toJSON` {#testrenderertojson}
108108

109109
```javascript
110110
testRenderer.toJSON()
111111
```
112112

113-
Return an object representing the rendered tree. This tree only contains the platform-specific nodes like `<div>` or `<View>` and their props, but doesn't contain any user-written components. This is handy for [snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest).
113+
ن يُمثِّل الشجرة المُصيَّرة. تحتوي هذه الشجرة على عُقَد خاصّة بالمنصّة مثل `<div>` ن يُمثِّل الشجرة المُصيَّرة. تحتوي هذه الشجرة على عُقَد خاصّة بالمنصّة مثل `<View>` وخاصيّاتها، ولكنّه لا يحتوي على مكوّنات مكتوبة من قبل المستخدم. يُفيد هذا لأجل[اختبار اللقطات (snapshot testing)](https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest).
114114

115-
### `testRenderer.toTree()` {#testrenderertotree}
115+
### `()testRenderer.toTree` {#testrenderertotree}
116116

117117
```javascript
118118
testRenderer.toTree()
119119
```
120120

121-
Return an object representing the rendered tree. Unlike `toJSON()`, the representation is more detailed than the one provided by `toJSON()`, and includes the user-written components. You probably don't need this method unless you're writing your own assertion library on top of the test renderer.
121+
يُعيد كائن يُمثِّل الشجرة المُصيَّرة. وعلى النقيض من التابع `toJSON()`‎ يكون التمثيل أكثر تفصيلًا ويتضمّن المكوّنات المكتوبة من قبل المستخدم. لن تحتاج هذا التابع غالبًا إلّا إذا كنت تكتب مكتبتك الخاصّة بناءً على مُصيِّر الاختبار.
122122

123-
### `testRenderer.update()` {#testrendererupdate}
123+
### `()testRenderer.update` {#testrendererupdate}
124124

125125
```javascript
126126
testRenderer.update(element)
127127
```
128128

129-
Re-render the in-memory tree with a new root element. This simulates a React update at the root. If the new element has the same type and key as the previous element, the tree will be updated; otherwise, it will re-mount a new tree.
129+
يُعيد تصيير الشجرة في الذاكرة مع عنصر جذري جديد. يُحاكي هذا تحديث React الذي يطرأ على العنصر الجذري. إن كان للعنصر الجديد نفس النوع والمفتاح للعنصر السابق فستُحدَّث الشجرة، وفيما عدا ذلك سيُعيد وصل شجرة جديدة.
130130

131-
### `testRenderer.unmount()` {#testrendererunmount}
131+
### `()testRenderer.unmount` {#testrendererunmount}
132132

133133
```javascript
134134
testRenderer.unmount()
135135
```
136136

137-
Unmount the in-memory tree, triggering the appropriate lifecycle events.
137+
يفصل الشجرة الموجودة في الذاكرة، وبذلك يُطلِق أحداث دورة الحياة المناسبة.
138138

139-
### `testRenderer.getInstance()` {#testrenderergetinstance}
139+
### `()testRenderer.getInstance` {#testrenderergetinstance}
140140

141141
```javascript
142142
testRenderer.getInstance()
143143
```
144144

145-
Return the instance corresponding to the root element, if available. This will not work if the root element is a function component because they don't have instances.
145+
يُعيد النسخة الموافقة للعنصر الجذري إن كانت موجودة. لن يعمل هذا التابع إن كان العنصر الجذري عبارة عن مكوّن دالة لأنّها لا تمتلك نُسَخًا مثل مكوّنات الأصناف.
146146

147147
### `testRenderer.root` {#testrendererroot}
148148

149149
```javascript
150150
testRenderer.root
151151
```
152152

153-
Returns the root "test instance" object that is useful for making assertions about specific nodes in the tree. You can use it to find other "test instances" deeper below.
153+
يُعيد نسخة الاختبار للكائن الجذري والتي تفيد في إجراء استعلامات حول عقد مُحدَّدة في شجرة المكوّنات. بإمكانك استخدامه لإيجاد نُسَخ الاختبار الأخرى الموجودة في مستويات أدنى من الشجرة.
154154

155-
### `testInstance.find()` {#testinstancefind}
155+
### `()testInstance.find` {#testinstancefind}
156156

157157
```javascript
158158
testInstance.find(test)
159159
```
160160

161-
Find a single descendant test instance for which `test(testInstance)` returns `true`. If `test(testInstance)` does not return `true` for exactly one test instance, it will throw an error.
161+
إيجاد نسخة الاختبار الوحيدة المنحدرة التي يُعيد فيها التابع `test(testInstance)` القيمة `true`. إن كان التابع `test(testInstance)`‎ لا يُعيد القيمة `true` لنسخة اختبار وحيدة بالضبط فسيرمي هذا التابع خطأً.
162162

163-
### `testInstance.findByType()` {#testinstancefindbytype}
163+
### `()testInstance.findByType` {#testinstancefindbytype}
164164

165165
```javascript
166166
testInstance.findByType(type)
167167
```
168168

169-
Find a single descendant test instance with the provided `type`. If there is not exactly one test instance with the provided `type`, it will throw an error.
169+
إيجاد نسخة اختبار وحيدة منحدرة من النوع المُعطى ضمن الوسيط `type`. إن لم يكن هنالك بالضبط نسخة اختبار وحيدة فسيرمي هذا التابع خطأً.
170170

171-
### `testInstance.findByProps()` {#testinstancefindbyprops}
171+
### `()testInstance.findByProps` {#testinstancefindbyprops}
172172

173173
```javascript
174174
testInstance.findByProps(props)
175175
```
176176

177-
Find a single descendant test instance with the provided `props`. If there is not exactly one test instance with the provided `props`, it will throw an error.
177+
إيجاد نسخة اختبار وحيدة منحدرة التي تمتلك الخاصيّات المُزوَّدة عن طريق الوسيط `props`. إن لم يكن هنالك بالضبط نسخة اختبار وحيدة تمتلك الخاصيّات المطلوبة فسيرمي هذا التابع خطأً.
178178

179-
### `testInstance.findAll()` {#testinstancefindall}
179+
### `()testInstance.findAll` {#testinstancefindall}
180180

181181
```javascript
182182
testInstance.findAll(test)
183183
```
184184

185-
Find all descendant test instances for which `test(testInstance)` returns `true`.
185+
إيجاد جميع نسخ الاختبار المنحدرة والتي يُعيد فيها التابع `test(testInstance)` القيمة `true`.
186186

187-
### `testInstance.findAllByType()` {#testinstancefindallbytype}
187+
### `()testInstance.findAllByType` {#testinstancefindallbytype}
188188

189189
```javascript
190190
testInstance.findAllByType(type)
191191
```
192192

193-
Find all descendant test instances with the provided `type`.
193+
إيجاد جميع نسخ الاختبار المنحدرة التي تمتلك النوع `type`.
194194

195195
### `testInstance.findAllByProps()` {#testinstancefindallbyprops}
196196

197197
```javascript
198198
testInstance.findAllByProps(props)
199199
```
200200

201-
Find all descendant test instances with the provided `props`.
201+
إيجاد جميع نسخ الاختبار المنحدرة التي تمتلك الخاصيّات `props`.
202202

203203
### `testInstance.instance` {#testinstanceinstance}
204204

205205
```javascript
206206
testInstance.instance
207207
```
208208

209-
The component instance corresponding to this test instance. It is only available for class components, as function components don't have instances. It matches the `this` value inside the given component.
209+
نسخة المكوّن المطابقة لنسخة الاختبار هذه. متوفّر فقط من أجل مكوّنات الأصناف، بسبب عدم امتلاك مكوّنات الدوال للنسخ. يُطابِق قيمة `this` بداخل المكوّن المُعطى.
210210

211211
### `testInstance.type` {#testinstancetype}
212212

213213
```javascript
214214
testInstance.type
215215
```
216216

217-
The component type corresponding to this test instance. For example, a `<Button />` component has a type of `Button`.
217+
نوع المكوّن المُطابِق لنسخة الاختبار هذه. على سبيل المثال يمتلك المكوّن `<Button />` النوع `Button`.
218218

219219
### `testInstance.props` {#testinstanceprops}
220220

221221
```javascript
222222
testInstance.props
223223
```
224224

225-
The props corresponding to this test instance. For example, a `<Button size="small" />` component has `{size: 'small'}` as props.
225+
الخاصيّات المطابقة لنسخة الاختبار هذه. على سبيل المثال يمتلك المكوّن `<Button size="small" />` الخاصيّة `{size: 'small'}` as props.
226226

227227
### `testInstance.parent` {#testinstanceparent}
228228

229229
```javascript
230230
testInstance.parent
231231
```
232232

233-
The parent test instance of this test instance.
233+
نسخة الاختبار الأب لنسخة الاختبار هذه.
234234

235235
### `testInstance.children` {#testinstancechildren}
236236

237237
```javascript
238238
testInstance.children
239239
```
240240

241-
The children test instances of this test instance.
241+
نسخة الاختبار الابن لنسخة الاختبار هذه.
242242

243-
## Ideas {#ideas}
243+
## بعض الأفكار {#ideas}
244244

245-
You can pass `createNodeMock` function to `TestRenderer.create` as the option, which allows for custom mock refs.
246-
`createNodeMock` accepts the current element and should return a mock ref object.
247-
This is useful when you test a component that relies on refs.
245+
بإمكانك تمرير الدالة `createNodeMock` إلى التابع `TestRenderer.create` كخيار، والذي يسمح بالمراجع المخصصة للمحاكاة. يقبل `createNodeMock` العنصر الحالي ويجب أن يُعيد كائن مرجع محاكي. يفيد هذا عند اختبار المكوّنات التي تعتمد على المراجع:
248246

249247
```javascript
250248
import TestRenderer from 'react-test-renderer';

0 commit comments

Comments
 (0)