Skip to content

Commit dfa8309

Browse files
authored
Translate 'Shallow Renderer' page (#24)
1 parent 72ddf8c commit dfa8309

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

content/docs/addons-shallow-renderer.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,63 @@ layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
**Importowanie**
1010

1111
```javascript
1212
import ShallowRenderer from 'react-test-renderer/shallow'; // ES6
13-
var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 with npm
13+
var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 z zainstalowanym npm
1414
```
1515

16-
## Overview {#overview}
16+
## Ogólne informacje {#overview}
1717

18-
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.
18+
Podczas pisania testów jednostkowych dla kodu reactowego przydatne może okazać się renderowanie płytkie (ang. *shallow rendering*). Pozwala ono na wyrenderowanie komponentu "jeden poziom w głąb" i wykonanie asercji na zwróconym drzewie, bez obaw o efekty uboczne komponentów potomnych, które wcale nie są tworzone i renderowane. Proces ten nie wymaga obecności drzewa DOM.
1919

20-
For example, if you have the following component:
20+
Załóżmy, że mamy do czynienia z następującym komponentem:
2121

2222
```javascript
2323
function MyComponent() {
2424
return (
2525
<div>
26-
<span className="heading">Title</span>
26+
<span className="heading">Tytuł</span>
2727
<Subcomponent foo="bar" />
2828
</div>
2929
);
3030
}
3131
```
3232

33-
Then you can assert:
33+
Można dla niego napisać taki oto test:
3434

3535
```javascript
3636
import ShallowRenderer from 'react-test-renderer/shallow';
3737

38-
// in your test:
38+
// w teście:
3939
const renderer = new ShallowRenderer();
4040
renderer.render(<MyComponent />);
4141
const result = renderer.getRenderOutput();
4242

4343
expect(result.type).toBe('div');
4444
expect(result.props.children).toEqual([
45-
<span className="heading">Title</span>,
45+
<span className="heading">Tytuł</span>,
4646
<Subcomponent foo="bar" />
4747
]);
4848
```
4949

50-
Shallow testing currently has some limitations, namely not supporting refs.
50+
Testowanie płytkie posiada obecnie pewne ograniczenia, jak choćby brak wsparcia dla referencji (ang. *refs*) komponentów.
5151

52-
> Note:
52+
> Uwaga:
5353
>
54-
> 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.
54+
> Zalecamy również zapoznanie się z [interefejsem API do płytkiego renderowania](https://airbnb.io/enzyme/docs/api/shallow.html) biblioteki Enzyme. Dostarcza ona tę samą funkcjonalność, jednak ma wygodniejszy i bardziej wysokopoziomowy interfejs.
5555
56-
## Reference {#reference}
56+
## Dokumentacja {#reference}
5757

5858
### `shallowRenderer.render()` {#shallowrendererrender}
5959

60-
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.
60+
`shallowRenderer` jest "miejscem", w którym można wyrenderować testowany komponent i otrzymać zwracaną przez niego strukturę.
6161

62-
`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.
62+
`shallowRenderer.render()` w działaniu przypomina [`ReactDOM.render()`](/docs/react-dom.html#render), jednak nie wymaga obecności drzewa DOM, a ponadto renderuje tylko jeden poziom struktury. Oznacza to, iż doskonale nadaje się do testowania komponentów w izolacji, bez brania pod uwagę implementacji komponentów potomnych.
6363

6464
### `shallowRenderer.getRenderOutput()` {#shallowrenderergetrenderoutput}
6565

66-
After `shallowRenderer.render()` has been called, you can use `shallowRenderer.getRenderOutput()` to get the shallowly rendered output.
66+
Po wywołaniu `shallowRenderer.render()` należy użyć `shallowRenderer.getRenderOutput()`, aby otrzymać płasko wyrenderowaną strukturę.
6767

68-
You can then begin to assert facts about the output.
68+
Można na niej wykonywać dowolne asercje.

0 commit comments

Comments
 (0)