Skip to content

Commit b7e1d7a

Browse files
Moved description from setp to example-react-intl
1 parent 753a27d commit b7e1d7a

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

docs/example-react-intl.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ title: React Intl
88
> If you want to combine setupTests with another setup you should check
99
> [`setup`](react-testing-library/setup.md)
1010
11+
## Configuring React-Intl Polyfills
12+
13+
If you're using React-Intl in your project, and you need to load a locale, you
14+
must load the Polyfills according to that language.
15+
16+
In order to do so, you may use this small setup and/or combine it with other
17+
setups.
18+
19+
```
20+
// src/setupTests.js
21+
import IntlPolyfill from 'intl'
22+
import 'intl/locale-data/jsonp/pt'
23+
24+
const setupTests = () => {
25+
// https://formatjs.io/guides/runtime-environments/#server
26+
if (global.Intl) {
27+
Intl.NumberFormat = IntlPolyfill.NumberFormat
28+
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat
29+
} else {
30+
global.Intl = IntlPolyfill
31+
}
32+
}
33+
34+
setupTests();
35+
```
36+
37+
A complete example:
38+
1139
```jsx
1240
import React from 'react'
1341
import 'jest-dom/extend-expect'

docs/react-testing-library/setup.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -226,29 +226,3 @@ mocha --require jsdom-global/register
226226
Note, depending on the version of Node you're running, you may also need to
227227
install @babel/polyfill (if you're using babel 7) or babel-polyfill (for babel
228228
6).
229-
230-
## Configuring React-Intl Polyfills
231-
232-
If you're using React-Intl in your project, and you need to load a locale, you
233-
must load the Polyfills according to that language.
234-
235-
In order to do so, you may use this small setup and/or combine it with other
236-
setups.
237-
238-
```
239-
// src/setupTests.js
240-
import IntlPolyfill from 'intl'
241-
import 'intl/locale-data/jsonp/pt'
242-
243-
const setupTests = () => {
244-
// https://formatjs.io/guides/runtime-environments/#server
245-
if (global.Intl) {
246-
Intl.NumberFormat = IntlPolyfill.NumberFormat
247-
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat
248-
} else {
249-
global.Intl = IntlPolyfill
250-
}
251-
}
252-
253-
setupTests();
254-
```

0 commit comments

Comments
 (0)