Skip to content

Commit 325762f

Browse files
henriquejensenglaucia86
authored andcommitted
Translate Shallow renderer (#32)
* Translate Shallow Renderer to pt-BR * Code Review fixes
1 parent c964771 commit 325762f

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,69 @@
11
---
22
id: shallow-renderer
3-
title: Shallow Renderer
3+
title: Renderização superficial (Shallow Renderer)
44
permalink: docs/shallow-renderer.html
55
layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
**Importando**
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 com npm
1414
```
1515

16-
## Overview {#overview}
16+
## Visão geral {#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+
Ao escrever testes unitários para o React, a renderização superficial pode ser útil. A renderização superficial o deixa renderizar um componente a um "nível simples de profundidade" e afirmar fatos sobre o que este método retorna, sem se preocupar sobre o comportamento dos componentes filhos, os quais não são instanciados ou renderizados. Isto não requer o DOM.
1919

20-
For example, if you have the following component:
20+
Por exemplo, se você tem o seguinte componente:
2121

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

33-
Then you can assert:
33+
Então pode afirmar:
3434

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

38-
// in your test:
38+
// no seu teste:
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">Título</span>,
4646
<Subcomponent foo="bar" />
4747
]);
4848
```
4949

50-
Shallow testing currently has some limitations, namely not supporting refs.
50+
O teste superficial atualmente tem algumas limitações, ou seja, não suporta refs.
5151

52-
> Note:
52+
> Nota:
5353
>
54-
> We also recommend checking out Enzyme's [Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality.
54+
> Nós também recomendamos verificar a [Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) da Enzyme. Ela fornece uma API de alto nível mais agradável sobre a mesma funcionalidade.
5555
56-
## Reference {#reference}
56+
## Referência {#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+
Você pode pensar no shallowRenderer como um "lugar" para renderizar o componente que você esta testando, e do qual irá extrair a saída do componente.
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()` é similar ao [`ReactDOM.render()`](/docs/react-dom.html#render) mas ela não requer o DOM e somente renderiza um nível simples de profundidade. Isto significa que você pode testar componentes isolados de como seus filhos são implementados.
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+
Depois do `shallowRenderer.render()` ter sido chamado, você pode usar `shallowRenderer.getRenderOutput()` para pegar a saída renderizada superficialmente.
6767

68-
You can then begin to assert facts about the output.
68+
69+
Você pode então começar a afirmar fatos sobre a saída.

0 commit comments

Comments
 (0)