Skip to content

Commit 66b0e09

Browse files
author
Gasim Gasimzada
authored
Merge pull request #85 from reactjs/translate-reference-test-renderer
Translate Test Renderer
2 parents aa11382 + c4fa8ba commit 66b0e09

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

content/docs/reference-test-renderer.md

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

9-
**Importing**
9+
**İdxal Etmə**
1010

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

16-
## Overview {#overview}
16+
## İcmal {#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+
Bu paket, React komponentlərini Javascript obyektlərinə render etmək üçün, DOM və ya nativ mobil mühitindən asılı olmayan React renderer-i təmin edir.
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+
Bu paket, React DOM və ya React Native komponentinin, brauzer və ya [jsdom](https://github.com/tmpvar/jsdom) olmadan render etdiyi platforma görünüş iyerarxiyasının snəpşotunu asan formada çəkməyə imkan yaradır.
2121

22-
Example:
22+
Məsələn:
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://jestjs.io/docs/en/snapshot-testing).
41+
JSON ağacının kopiyasını yadda saxlayıb testlərdə bu ağacın dəyişdiyini yoxlamaq üçün Jest-in snəpşot test xüsusiyyətindən istifadə edə bilərsiniz. [Əlavə məlumat üçün bura baxın](https://jestjs.io/docs/en/snapshot-testing).
4242

43-
You can also traverse the output to find specific nodes and make assertions about them.
43+
Həmçinin siz nəticənin üzərindən keçib lazım olan nodları tapa bilər və bu nodlar üzərində iddialarınızı yoxlaya bilərsiniz.
4444

4545
```javascript
4646
import TestRenderer from 'react-test-renderer';
@@ -49,7 +49,7 @@ function MyComponent() {
4949
return (
5050
<div>
5151
<SubComponent foo="bar" />
52-
<p className="my">Hello</p>
52+
<p className="my">Salam</p>
5353
</div>
5454
)
5555
}
@@ -72,7 +72,7 @@ expect(testInstance.findByProps({className: "sub"}).children).toEqual(['Sub']);
7272
* [`TestRenderer.create()`](#testrenderercreate)
7373
* [`TestRenderer.act()`](#testrendereract)
7474

75-
### TestRenderer instance {#testrenderer-instance}
75+
### TestRenderer instansiyası {#testrenderer-instance}
7676

7777
* [`testRenderer.toJSON()`](#testrenderertojson)
7878
* [`testRenderer.toTree()`](#testrenderertotree)
@@ -95,43 +95,44 @@ expect(testInstance.findByProps({className: "sub"}).children).toEqual(['Sub']);
9595
* [`testInstance.parent`](#testinstanceparent)
9696
* [`testInstance.children`](#testinstancechildren)
9797

98-
## Reference {#reference}
98+
## Arayış {#reference}
9999

100100
### `TestRenderer.create()` {#testrenderercreate}
101101

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

106-
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. Returns a [TestRenderer instance](#testrenderer-instance).
106+
Göndərilən React elementi ilə `TestRenderer` instansiyası yaradın. Bunun real DOM-dan istifadə etməməsinə baxmayaraq, iddialarımızı yoxlaya bilmək üçün komponent ağacı yenə də bütünlüklə yaddaşa render edilir. Qaytarılan instansiyanın funksiya və parametrləri aşağıda göstərilib.
107107

108108
### `TestRenderer.act()` {#testrendereract}
109109

110110
```javascript
111111
TestRenderer.act(callback);
112112
```
113113

114-
Similar to the [`act()` helper from `react-dom/test-utils`](/docs/test-utils.html#act), `TestRenderer.act` prepares a component for assertions. Use this version of `act()` to wrap calls to `TestRenderer.create` and `testRenderer.update`.
114+
`TestRenderer.act`, [`react-dom/test-utils`-də olan `act()` köməkçisi kimi](/docs/test-utils.html#act) iddialarınızı yoxlamaq üçün komponentləri hazırlayır. `act()`-in bu versiyasını `TestRenderer.create` `testRenderer.update` çağırışlarını əhatə etmək üçün işlədin.
115115

116116
```javascript
117117
import {create, act} from 'react-test-renderer';
118-
import App from './app.js'; // The component being tested
118+
import App from './app.js'; // Test edilən komponent
119119

120-
// render the component
120+
// komponenti render et
121121
let root;
122122
act(() => {
123123
root = create(<App value={1}/>)
124124
});
125125

126-
// make assertions on root
126+
127+
// ana komponentin üzərində iddaları yoxlayın
127128
expect(root.toJSON()).toMatchSnapshot();
128129

129-
// update with some different props
130+
// fərqli proplar ilə yeniləyin
130131
act(() => {
131132
root = root.update(<App value={2}/>);
132133
})
133134

134-
// make assertions on root
135+
// ana komponentin üzərində iddaları yoxlayın
135136
expect(root.toJSON()).toMatchSnapshot();
136137
```
137138

@@ -141,141 +142,141 @@ expect(root.toJSON()).toMatchSnapshot();
141142
testRenderer.toJSON()
142143
```
143144

144-
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).
145+
Render edilmiş ağacı təmsil edən obyekti qaytarır. Render edilmiş ağac yalnız `<div>` və ya `<View>` kimi platform-spesifik nodlardan ibarətdir. Bu ağacda istifadəçi tərəfindən yaranmış komponentlər olmur. [Snəpşot testi üçün](https://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest) faydalıdır.
145146

146147
### `testRenderer.toTree()` {#testrenderertotree}
147148

148149
```javascript
149150
testRenderer.toTree()
150151
```
151152

152-
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.
153+
Render edilmiş ağacı təmsil edən obyekti qaytarır. `toJSON()`-dan fərqli olaraq bu funksiya istifadəçi tərəfindən yaranmış komponentləri də obyektə daxil edir. Siz test renderer üzərində öz test kitabxananızı yazmırsınızsa, bu funksiya sizə lazım deyil.
153154

154155
### `testRenderer.update()` {#testrendererupdate}
155156

156157
```javascript
157158
testRenderer.update(element)
158159
```
159160

160-
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.
161+
Yaddaşda olan ağacı yeni ana elementi ilə yenidən render edin. Bu funksiya React-in ana komponentdə yenilənməsini simulyasiya edir. Əgər yeni elementin tipi və açarı keçmiş elementinki ilə eynidirsə ağac yenilənəcək. Əks halda yeni ağac mount olunacaq.
161162

162163
### `testRenderer.unmount()` {#testrendererunmount}
163164

164165
```javascript
165166
testRenderer.unmount()
166167
```
167168

168-
Unmount the in-memory tree, triggering the appropriate lifecycle events.
169+
Yaddaşda olan ağacı unmount edib uyğun lifecycle hadisələrini çağırın.
169170

170171
### `testRenderer.getInstance()` {#testrenderergetinstance}
171172

172173
```javascript
173174
testRenderer.getInstance()
174175
```
175176

176-
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.
177+
Əgər mümkündürsə, ana elementin instansiyasını qaytarın. Əgər ana element funksiya komponentidirsə bu funksiya işləməyəcək. Çünki funksiya komponentlərinin instansiyaları olmur.
177178

178179
### `testRenderer.root` {#testrendererroot}
179180

180181
```javascript
181182
testRenderer.root
182183
```
183184

184-
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.
185+
Ağacda olan spesifik nodlar haqqında iddiaları yaratmaq üçün faydalı olan ana "test instansiya" obyektini qaytarın. Siz bu instansiya ilə dərində olan digər "test instansiyalarını" tapa bilərsiniz.
185186

186187
### `testInstance.find()` {#testinstancefind}
187188

188189
```javascript
189190
testInstance.find(test)
190191
```
191192

192-
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.
193+
`test(testInstance)` `true` qaytaran tək test instansiyasını tapın. Əgər `test(testInstance)` yalnız tək instansiya üçün `true` qaytarmırsa bu funksiya istisna atacaq.
193194

194195
### `testInstance.findByType()` {#testinstancefindbytype}
195196

196197
```javascript
197198
testInstance.findByType(type)
198199
```
199200

200-
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.
201+
Təmin edilən `type` ilə tək test instansiyasını tapın. Əgər təmin edilən `type` ilə yalnız tək instansiya yoxdursa bu funksiya istisna atacaq.
201202

202203
### `testInstance.findByProps()` {#testinstancefindbyprops}
203204

204205
```javascript
205206
testInstance.findByProps(props)
206207
```
207208

208-
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.
209+
Təmin edilən `props` ilə tək test instansiyasını tapın. Əgər təmin edilən `props` ilə yalnız tək instansiya yoxdursa, bu funksiya istisna atacaq.
209210

210211
### `testInstance.findAll()` {#testinstancefindall}
211212

212213
```javascript
213214
testInstance.findAll(test)
214215
```
215216

216-
Find all descendant test instances for which `test(testInstance)` returns `true`.
217+
`test(testInstance)` `true` qaytaran bütün test instansiyalarını tapın.
217218

218219
### `testInstance.findAllByType()` {#testinstancefindallbytype}
219220

220221
```javascript
221222
testInstance.findAllByType(type)
222223
```
223224

224-
Find all descendant test instances with the provided `type`.
225+
Təmin edilən `type` ilə bütün test instansiyalarını tapın.
225226

226227
### `testInstance.findAllByProps()` {#testinstancefindallbyprops}
227228

228229
```javascript
229230
testInstance.findAllByProps(props)
230231
```
231232

232-
Find all descendant test instances with the provided `props`.
233+
Təmin edilən `props` ilə bütün test instansiyalarını tapın.
233234

234235
### `testInstance.instance` {#testinstanceinstance}
235236

236237
```javascript
237238
testInstance.instance
238239
```
239240

240-
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.
241+
Göstərilən test instansiyasına uyğun olan komponent. Funksiya komponentlərinin instansiyaları olmadığından bu yalnız klas komponentləri üçün mövcuddur. Verilən komponentin `this` dəyəri ilə uyğundur.
241242

242243
### `testInstance.type` {#testinstancetype}
243244

244245
```javascript
245246
testInstance.type
246247
```
247248

248-
The component type corresponding to this test instance. For example, a `<Button />` component has a type of `Button`.
249+
Test instansiyasının komponent tipi. Məsələn, `<Button />` komponentinin tipi `Button`-dır.
249250

250251
### `testInstance.props` {#testinstanceprops}
251252

252253
```javascript
253254
testInstance.props
254255
```
255256

256-
The props corresponding to this test instance. For example, a `<Button size="small" />` component has `{size: 'small'}` as props.
257+
Test instansiyasına uyğun gələn proplar. Məsələn, `<Button size="small" />` komponentinin `{size: 'small'}` propları var.
257258

258259
### `testInstance.parent` {#testinstanceparent}
259260

260261
```javascript
261262
testInstance.parent
262263
```
263264

264-
The parent test instance of this test instance.
265+
Test instansiyasının ana test instansiyası.
265266

266267
### `testInstance.children` {#testinstancechildren}
267268

268269
```javascript
269270
testInstance.children
270271
```
271272

272-
The children test instances of this test instance.
273+
Test instansiyasının uşaq test instansiyaları.
273274

274-
## Ideas {#ideas}
275+
## İdeyalar {#ideas}
275276

276-
You can pass `createNodeMock` function to `TestRenderer.create` as the option, which allows for custom mock refs.
277-
`createNodeMock` accepts the current element and should return a mock ref object.
278-
This is useful when you test a component that relies on refs.
277+
Xüsusi mok refləri düzəltmək üçün `TestRenderer.create``createNodeMock` funksiyasını göndərə bilərsiniz.
278+
`createNodeMock` cari elementi qəbul edir və mok ref obyekti qaytarır.
279+
Bu ref-lərdən asılı olan komponentləri test etmək üçün faydalıdır.
279280

280281
```javascript
281282
import TestRenderer from 'react-test-renderer';
@@ -299,7 +300,7 @@ TestRenderer.create(
299300
{
300301
createNodeMock: (element) => {
301302
if (element.type === 'input') {
302-
// mock a focus function
303+
// fokus funksiyasını mok edin
303304
return {
304305
focus: () => {
305306
focused = true;

0 commit comments

Comments
 (0)