Skip to content

Commit fb2a1c8

Browse files
deblasisLucaBlackDragon
authored andcommitted
Translation for the page 'API Reference -> Shallow Renderer' (#131)
* shallow-renderer: done Signed-off-by: Alessandro De Blasis <alex@deblasis.net> * quote Signed-off-by: Alessandro De Blasis <alex@deblasis.net> * nav Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
1 parent 213b6db commit fb2a1c8

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,72 @@
11
---
22
id: shallow-renderer
3-
title: Shallow Renderer
3+
title: Renderizzatore Shallow
44
permalink: docs/shallow-renderer.html
55
layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
> **Nota sulla traduzione:**
10+
>
11+
> La definizione inglese `Shallow Renderer` si traduce letteralmente in `Renderizzatore Superficiale`, dato che il modulo è chiamato `shallow`, abbiamo deciso di non tradurlo di seguito.
12+
13+
**Importazione**
1014

1115
```javascript
1216
import ShallowRenderer from 'react-test-renderer/shallow'; // ES6
13-
var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 with npm
17+
var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 con npm
1418
```
1519

16-
## Overview {#overview}
20+
## Panoramica {#overview}
1721

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.
22+
Quando scriviamo unit test per React, la renderizzazione shallow può tornare molto utile. Essa permette di renderizzare un componente "ad un livello di profondità" e di asserire fatti riguardo cosa viene ritornato dal suo metodo `render`. Il vantaggio risiede nel fatto che non dobbiamo preoccuparci del comportamento dei componenti figli, i quali non vengono istanziati o renderizzati. Non è richiesto nemmeno un DOM.
1923

20-
For example, if you have the following component:
24+
Ad esempio, dato il seguente componente:
2125

2226
```javascript
23-
function MyComponent() {
27+
function MioComponente() {
2428
return (
2529
<div>
26-
<span className="heading">Title</span>
27-
<Subcomponent foo="bar" />
30+
<span className="testata">Titolo</span>
31+
<SottoComponente foo="bar" />
2832
</div>
2933
);
3034
}
3135
```
3236

33-
Then you can assert:
37+
Possiamo asserire:
3438

3539
```javascript
3640
import ShallowRenderer from 'react-test-renderer/shallow';
3741

38-
// in your test:
42+
// nel tuo test:
3943
const renderer = new ShallowRenderer();
40-
renderer.render(<MyComponent />);
44+
renderer.render(<MioComponente />);
4145
const result = renderer.getRenderOutput();
4246

4347
expect(result.type).toBe('div');
4448
expect(result.props.children).toEqual([
45-
<span className="heading">Title</span>,
46-
<Subcomponent foo="bar" />
49+
<span className="testata">Titolo</span>,
50+
<SottoComponente foo="bar" />
4751
]);
4852
```
4953

50-
Shallow testing currently has some limitations, namely not supporting refs.
54+
Il testing shallow, attualmente, ha alcune limitazioni quali il mancato supporto ai `refs`.
5155

52-
> Note:
56+
> Nota:
5357
>
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.
58+
> Ti raccomandiamo inoltre di dare uno sguardo alle [API Shallow Rendering](https://airbnb.io/enzyme/docs/api/shallow.html) di Enzyme. Ti offrono una migliore API di più alto livello attorno alla stessa funzionalità.
5559
56-
## Reference {#reference}
60+
## Riferimento {#reference}
5761

5862
### `shallowRenderer.render()` {#shallowrendererrender}
5963

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.
64+
Puoi pensare allo _shallowRenderer_ come ad un "posto" nel quale renderizzare i componenti che stai testando, dal quale puoi estrarre l'output del componente.
6165

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.
66+
`shallowRenderer.render()` è simile a [`ReactDOM.render()`](/docs/react-dom.html#render) ma non richiede un DOM e renderizza ad un solo livello di profondità. Ciò significa che potrai testare i componenti in isolamento rispetto a come sono implementati i componenti figli.
6367

6468
### `shallowRenderer.getRenderOutput()` {#shallowrenderergetrenderoutput}
6569

66-
After `shallowRenderer.render()` has been called, you can use `shallowRenderer.getRenderOutput()` to get the shallowly rendered output.
70+
Quando `shallowRenderer.render()` è stato chiamato, puoi usare `shallowRenderer.getRenderOutput()` per ottenere l'output renderizzato in modo "superficiale".
6771

68-
You can then begin to assert facts about the output.
72+
Potrai allora asserire fatti riguardo ad esso nei tuoi test.

content/docs/nav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
- id: test-utils
9898
title: Test Utilities
9999
- id: shallow-renderer
100-
title: Shallow Renderer
100+
title: Renderizzatore Shallow
101101
- id: test-renderer
102102
title: Test Renderer
103103
- id: javascript-environment-requirements

0 commit comments

Comments
 (0)