Skip to content

Commit cbc8ed0

Browse files
authored
Merge pull request #53 from reactjs/api/test-utils
Test Utils translation
2 parents 7841566 + de4b236 commit cbc8ed0

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

content/docs/addons-test-utils.md

+53-53
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
id: test-utils
3-
title: Test Utilities
3+
title: Tesztelői segédeszközök
44
permalink: docs/test-utils.html
55
layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
**Importálás**
1010

1111
```javascript
1212
import ReactTestUtils from 'react-dom/test-utils'; // ES6
13-
var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
13+
var ReactTestUtils = require('react-dom/test-utils'); // ES5 npm-mel
1414
```
1515

16-
## Overview {#overview}
16+
## Áttekintés {#overview}
1717

18-
`ReactTestUtils` makes it easy to test React components in the testing framework of your choice. At Facebook we use [Jest](https://facebook.github.io/jest/) for painless JavaScript testing. Learn how to get started with Jest through the Jest website's [React Tutorial](https://jestjs.io/docs/tutorial-react).
18+
A `ReactTestUtils` egyszerűvé teszi a React komponensek tesztelését az általad választott tesztelői keretrendszerben. A Facebooknál a [Jest](https://facebook.github.io/jest/)-et használjuk a fájdalommentes JavaScript tesztelés érdekében. A Jest weboldalán lévő [React Tutorial](https://jestjs.io/docs/tutorial-react) segítségével megtanulhatod, hogy kezdhetsz neki a tesztelésnek.
1919

20-
> Note:
20+
> Megjegyzés:
2121
>
22-
> We recommend using [React Testing Library](https://testing-library.com/react) which is designed to enable and encourage writing tests that use your components as the end users do.
22+
> Mi a [React Testing Library](https://testing-library.com/react) használatát ajánljuk, ami úgy lett tervezve, hogy olyan komponenstesztek írására bátorítson, amik a végfelhasználó cselekedeit tükrözi.
2323
>
24-
> Alternatively, Airbnb has released a testing utility called [Enzyme](https://airbnb.io/enzyme/), which makes it easy to assert, manipulate, and traverse your React Components' output.
24+
> Alternatívaként, az Airbnb is kiadott egy tesztelői segédeszközt [Enzyme](https://airbnb.io/enzyme/) néven, ami egyszerűbbé teszi a React komponenseid kimenetéhez állításokat írni, azt manipulálni és bejárni.
2525
2626
- [`act()`](#act)
2727
- [`mockComponent()`](#mockcomponent)
@@ -40,17 +40,17 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
4040
- [`renderIntoDocument()`](#renderintodocument)
4141
- [`Simulate`](#simulate)
4242

43-
## Reference {#reference}
43+
## Referencia {#reference}
4444

4545
### `act()` {#act}
4646

47-
To prepare a component for assertions, wrap the code rendering it and performing updates inside an `act()` call. This makes your test run closer to how React works in the browser.
47+
Egy komponens állításokhoz való felkészítéshez vedd körül az azt renderelő és frissítéseket végrehajtó kódot egy `act()` hívással. Ez közelebb viszi a tesztek futtatását ahhoz, ahogyan a React működik a böngészőben.
4848

49-
>Note
49+
>Megjegyzés
5050
>
51-
>If you use `react-test-renderer`, it also provides an `act` export that behaves the same way.
51+
> Ha a `react-test-renderer`-t használod, az is szolgáltat egy `act` exportot, ami hasonlóan működik.
5252
53-
For example, let's say we have this `Counter` component:
53+
Például, mondjuk hogy van ez a `Counter` komponensünk:
5454

5555
```js
5656
class Counter extends React.Component {
@@ -60,10 +60,10 @@ class Counter extends React.Component {
6060
this.handleClick = this.handleClick.bind(this);
6161
}
6262
componentDidMount() {
63-
document.title = `You clicked ${this.state.count} times`;
63+
document.title = `${this.state.count} alkalommal kattintottál`;
6464
}
6565
componentDidUpdate() {
66-
document.title = `You clicked ${this.state.count} times`;
66+
document.title = `${this.state.count} alkalommal kattintottál`;
6767
}
6868
handleClick() {
6969
this.setState(state => ({
@@ -73,17 +73,17 @@ class Counter extends React.Component {
7373
render() {
7474
return (
7575
<div>
76-
<p>You clicked {this.state.count} times</p>
76+
<p>{this.state.count} alkalommal kattintottál</p>
7777
<button onClick={this.handleClick}>
78-
Click me
78+
Kattints rám
7979
</button>
8080
</div>
8181
);
8282
}
8383
}
8484
```
8585

86-
Here is how we can test it:
86+
Ezt így tudjuk tesztelni:
8787

8888
```js{3,20-22,29-31}
8989
import React from 'react';
@@ -103,28 +103,28 @@ afterEach(() => {
103103
container = null;
104104
});
105105
106-
it('can render and update a counter', () => {
107-
// Test first render and componentDidMount
106+
it('tud egy számlálót renderelni, és frissíteni', () => {
107+
// Teszteld az első renderelést és a componentDidMount-ot
108108
act(() => {
109109
ReactDOM.render(<Counter />, container);
110110
});
111111
const button = container.querySelector('button');
112112
const label = container.querySelector('p');
113-
expect(label.textContent).toBe('You clicked 0 times');
114-
expect(document.title).toBe('You clicked 0 times');
113+
expect(label.textContent).toBe('0 alkalommal kattintottál');
114+
expect(document.title).toBe('0 alkalommal kattintottál');
115115
116-
// Test second render and componentDidUpdate
116+
// Teszteld a második renderelést, és a componentDidUpdate-t
117117
act(() => {
118118
button.dispatchEvent(new MouseEvent('click', {bubbles: true}));
119119
});
120-
expect(label.textContent).toBe('You clicked 1 times');
121-
expect(document.title).toBe('You clicked 1 times');
120+
expect(label.textContent).toBe('1 alkalommal kattintottál');
121+
expect(document.title).toBe('1 alkalommal kattintottál');
122122
});
123123
```
124124

125-
- Don't forget that dispatching DOM events only works when the DOM container is added to the `document`. You can use a library like [React Testing Library](https://testing-library.com/react) to reduce the boilerplate code.
125+
- Ne feledd, hogy DOM események kiküldése csak akkor működik, ha a DOM konténer hozzá lett adva a `document`-hez. A sablonkód minimalizálásához használj egy könyvtárat, mint a [React Testing Library](https://testing-library.com/react).
126126

127-
- The [`recipes`](/docs/testing-recipes.html) document contains more details on how `act()` behaves, with examples and usage.
127+
- A [`receptek`](/docs/testing-recipes.html) dokumentum több részletet tartalmaz az `act()` működéséről példákkal, és annak használatáról.
128128

129129
* * *
130130

@@ -137,11 +137,11 @@ mockComponent(
137137
)
138138
```
139139

140-
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
140+
Adj át egy leutánzott (mocked) komponensmodult ennek a metódusnak, hogy azt kiterjeszd hasznos metódusokkal, amik lehetővé teszik ezt úgy használni, mint egy ál-React komponenst. Szokásos renderelés helyett a komponens egy egyszerű `<div>`-vé válik (vagy más címkévé, ha a `mockTagName` meg lett adva), ami minden szolgáltatott gyermeket tartalmaz.
141141

142-
> Note:
142+
> Megjegyzés:
143143
>
144-
> `mockComponent()` is a legacy API. We recommend using [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock) instead.
144+
> A `mockComponent()` egy elavult API. Helyette a [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock) használatát ajánljuk.
145145
146146
* * *
147147

@@ -151,7 +151,7 @@ Pass a mocked component module to this method to augment it with useful methods
151151
isElement(element)
152152
```
153153

154-
Returns `true` if `element` is any React element.
154+
Ha az `element` egy bármilyen React elem, `true` értéket ad vissza.
155155

156156
* * *
157157

@@ -164,7 +164,7 @@ isElementOfType(
164164
)
165165
```
166166

167-
Returns `true` if `element` is a React element whose type is of a React `componentClass`.
167+
Ha az `element` egy bármilyen React elem, aminek a típusa `componentClass`, akkor `true` értéket ad vissza.
168168

169169
* * *
170170

@@ -174,7 +174,7 @@ Returns `true` if `element` is a React element whose type is of a React `compone
174174
isDOMComponent(instance)
175175
```
176176

177-
Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
177+
Ha az `instance` egy DOM komponens (mint például `<div>`, vagy `<span>`), akkor `true` értéket ad vissza.
178178

179179
* * *
180180

@@ -184,7 +184,7 @@ Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
184184
isCompositeComponent(instance)
185185
```
186186

187-
Returns `true` if `instance` is a user-defined component, such as a class or a function.
187+
Ha az `instance` egy felhasználó által definiált komponens, mint például egy osztály vagy egy függvény, akkor `true` értéket ad vissza.
188188

189189
* * *
190190

@@ -197,7 +197,7 @@ isCompositeComponentWithType(
197197
)
198198
```
199199

200-
Returns `true` if `instance` is a component whose type is of a React `componentClass`.
200+
Ha az `instance` egy React komponens, aminek a típusa egy `componentClass`, akkor `true` értéket ad vissza.
201201

202202
* * *
203203

@@ -210,7 +210,7 @@ findAllInRenderedTree(
210210
)
211211
```
212212

213-
Traverse all components in `tree` and accumulate all components where `test(component)` is `true`. This is not that useful on its own, but it's used as a primitive for other test utils.
213+
Bejár minden komponenst a `tree`-ben (fán) és összegyűjti az összes komponenst, ahol a `test(component)` `true`. Ez így magában nem túl hasznos, inkább primitívként, más tesztelői segédeszközökben használt.
214214

215215
* * *
216216

@@ -223,7 +223,7 @@ scryRenderedDOMComponentsWithClass(
223223
)
224224
```
225225

226-
Finds all DOM elements of components in the rendered tree that are DOM components with the class name matching `className`.
226+
Megtalálja minden komponens DOM elemét a renderelt fában, amik DOM komponensek, és osztálynevük megegyezik a `className`-mel.
227227

228228
* * *
229229

@@ -236,7 +236,7 @@ findRenderedDOMComponentWithClass(
236236
)
237237
```
238238

239-
Like [`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass) but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
239+
Mint a [`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass), de csak egy eredményre számít, és csak ezt az egy eredményt adja vissza, vagy egy kivételt dob, ha több egyezés is van.
240240

241241
* * *
242242

@@ -249,7 +249,7 @@ scryRenderedDOMComponentsWithTag(
249249
)
250250
```
251251

252-
Finds all DOM elements of components in the rendered tree that are DOM components with the tag name matching `tagName`.
252+
Megtalálja minden komponens DOM elemét a renderelt fában, amik DOM komponensek, és címkenevük megegyezik a `tagName`-mel.
253253

254254
* * *
255255

@@ -262,7 +262,7 @@ findRenderedDOMComponentWithTag(
262262
)
263263
```
264264

265-
Like [`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag) but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
265+
Mint a [`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag), de csak egy eredményre számít, és csak ezt az egy eredményt adja vissza, vagy egy kivételt dob, ha több egyezés is van.
266266

267267
* * *
268268

@@ -275,7 +275,7 @@ scryRenderedComponentsWithType(
275275
)
276276
```
277277

278-
Finds all instances of components with type equal to `componentClass`.
278+
Megtalálja az összes komponens példányát, amik típusa megegyezik a `componentClass`-szal.
279279

280280
* * *
281281

@@ -288,7 +288,7 @@ findRenderedComponentWithType(
288288
)
289289
```
290290

291-
Same as [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
291+
Mint a [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype), de csak egy eredményre számít, és csak ezt az egy eredményt adja vissza, vagy egy kivételt dob, ha több egyezés is van.
292292

293293
***
294294

@@ -298,20 +298,20 @@ Same as [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) bu
298298
renderIntoDocument(element)
299299
```
300300

301-
Render a React element into a detached DOM node in the document. **This function requires a DOM.** It is effectively equivalent to:
301+
Egy React elemet renderel egy leválasztott DOM csomópontba, a dokumentumban. **Ez a függvény megköveteli a DOM jelenlétét.** Ez végülis ekvivalens ezzel:
302302

303303
```js
304304
const domContainer = document.createElement('div');
305305
ReactDOM.render(element, domContainer);
306306
```
307307

308-
> Note:
308+
> Megegyezés:
309309
>
310-
> You will need to have `window`, `window.document` and `window.document.createElement` globally available **before** you import `React`. Otherwise React will think it can't access the DOM and methods like `setState` won't work.
310+
> Szükséged lesz a `window`, `window.document` és a `window.document.createElement` globális jelenlétére a `React` beimportálása **előtt**. Máskülönben a React azt fogja hinni, hogy nem fér hozzá a DOM-hoz és olyan metódusok, mint a `setState` nem fognak működni.
311311
312312
* * *
313313

314-
## Other Utilities {#other-utilities}
314+
## Egyéb segédeszközök {#other-utilities}
315315

316316
### `Simulate` {#simulate}
317317

@@ -322,30 +322,30 @@ Simulate.{eventName}(
322322
)
323323
```
324324

325-
Simulate an event dispatch on a DOM node with optional `eventData` event data.
325+
Egy esemény kiküldését szimulálja egy DOM csompóponton, az opcionális `eventData` eseménnyel kapcsolatos adattal.
326326

327-
`Simulate` has a method for [every event that React understands](/docs/events.html#supported-events).
327+
A `Simulate` rendelkezik egy metódussal [minden eseményhez, amit a React megért](/docs/events.html#supported-events).
328328

329-
**Clicking an element**
329+
**Egy elemre kattintás**
330330

331331
```javascript
332332
// <button ref={(node) => this.button = node}>...</button>
333333
const node = this.button;
334334
ReactTestUtils.Simulate.click(node);
335335
```
336336

337-
**Changing the value of an input field and then pressing ENTER.**
337+
**Beviteli mező értékének megváltoztatása és az ENTER lenyomása.**
338338

339339
```javascript
340340
// <input ref={(node) => this.textInput = node} />
341341
const node = this.textInput;
342-
node.value = 'giraffe';
342+
node.value = 'zsiráf';
343343
ReactTestUtils.Simulate.change(node);
344344
ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});
345345
```
346346

347-
> Note
347+
> Megjegyzés
348348
>
349-
> You will have to provide any event property that you're using in your component (e.g. keyCode, which, etc...) as React is not creating any of these for you.
349+
> Minden eseménytulajdonságot szolgáltatnod kell, amit a komponensed használ (pl.: keyCode, which, stb...), mivel a React ezeket nem fogja neked létrehozni.
350350
351351
* * *

content/docs/nav.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
- id: events
100100
title: SyntheticEvent
101101
- id: test-utils
102-
title: Tesztelői segédprogramok
102+
title: Tesztelői segédeszközök
103103
- id: test-renderer
104104
title: Teszt renderelő
105105
- id: javascript-environment-requirements

0 commit comments

Comments
 (0)