diff --git a/.all-contributorsrc b/.all-contributorsrc index de679507..027204fd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -708,6 +708,16 @@ "bug", "code" ] + }, + { + "login": "viniciusavieira", + "name": "Vinicius", + "avatar_url": "https://avatars0.githubusercontent.com/u/2073019?v=4", + "profile": "https://github.com/viniciusavieira", + "contributions": [ + "doc", + "example" + ] } ], "contributorsPerLine": 7 diff --git a/README.md b/README.md index d6c46844..234eb7cc 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ practices.

[![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-73-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] [![Join the community on Spectrum][spectrum-badge]][spectrum] @@ -221,7 +221,8 @@ Thanks goes to these people ([emoji key][emojis]): | [Michiel Nuyts
Michiel Nuyts](https://github.com/Michielnuyts)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=Michielnuyts "Documentation") | [Joe Ng'ethe
Joe Ng'ethe](https://github.com/joeynimu)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Code") [πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Documentation") | [Kate
Kate](https://github.com/Enikol)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=Enikol "Documentation") | [Sean
Sean](http://www.seanrparker.com)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=SeanRParker "Documentation") | [James Long
James Long](http://jlongster.com)
[πŸ€”](#ideas-jlongster "Ideas, Planning, & Feedback") [πŸ“¦](#platform-jlongster "Packaging/porting to new platform") | [Herb Hagely
Herb Hagely](https://github.com/hhagely)
[πŸ’‘](#example-hhagely "Examples") | [Alex Wendte
Alex Wendte](http://www.wendtedesigns.com/)
[πŸ’‘](#example-themostcolm "Examples") | | [Monica Powell
Monica Powell](http://www.aboutmonica.com)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=M0nica "Documentation") | [Vitaly Sivkov
Vitaly Sivkov](http://sivkoff.com)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=sivkoff "Code") | [Weyert de Boer
Weyert de Boer](https://github.com/weyert)
[πŸ€”](#ideas-weyert "Ideas, Planning, & Feedback") [πŸ‘€](#review-weyert "Reviewed Pull Requests") | [EstebanMarin
EstebanMarin](https://github.com/EstebanMarin)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=EstebanMarin "Documentation") | [Victor Martins
Victor Martins](https://github.com/vctormb)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=vctormb "Documentation") | [Royston Shufflebotham
Royston Shufflebotham](https://github.com/RoystonS)
[πŸ›](https://github.com/kentcdodds/react-testing-library/issues?q=author%3ARoystonS "Bug reports") [πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=RoystonS "Documentation") [πŸ’‘](#example-RoystonS "Examples") | [chrbala
chrbala](https://github.com/chrbala)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=chrbala "Code") | | [Donavon West
Donavon West](http://donavon.com)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Code") [πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Documentation") [πŸ€”](#ideas-donavon "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Tests") | [Richard Maisano
Richard Maisano](https://github.com/maisano)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=maisano "Code") | [Marco Biedermann
Marco Biedermann](https://www.marcobiedermann.com)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=marcobiedermann "Code") [🚧](#maintenance-marcobiedermann "Maintenance") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=marcobiedermann "Tests") | [Alex Zherdev
Alex Zherdev](https://github.com/alexzherdev)
[πŸ›](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Aalexzherdev "Bug reports") [πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=alexzherdev "Code") | [AndrΓ© Matulionis dos Santos
AndrΓ© Matulionis dos Santos](https://twitter.com/Andrewmat)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=Andrewmat "Code") [πŸ’‘](#example-Andrewmat "Examples") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=Andrewmat "Tests") | [Daniel K.
Daniel K.](https://github.com/FredyC)
[πŸ›](https://github.com/kentcdodds/react-testing-library/issues?q=author%3AFredyC "Bug reports") [πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=FredyC "Code") [πŸ€”](#ideas-FredyC "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=FredyC "Tests") | [mohamedmagdy17593
mohamedmagdy17593](https://github.com/mohamedmagdy17593)
[πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=mohamedmagdy17593 "Code") | -| [Loren ☺️
Loren ☺️](http://lorensr.me)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=lorensr "Documentation") | [MarkFalconbridge
MarkFalconbridge](https://github.com/MarkFalconbridge)
[πŸ›](https://github.com/kentcdodds/react-testing-library/issues?q=author%3AMarkFalconbridge "Bug reports") [πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=MarkFalconbridge "Code") | +| [Loren ☺️
Loren ☺️](http://lorensr.me)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=lorensr "Documentation") | [MarkFalconbridge
MarkFalconbridge](https://github.com/MarkFalconbridge)
[πŸ›](https://github.com/kentcdodds/react-testing-library/issues?q=author%3AMarkFalconbridge "Bug reports") [πŸ’»](https://github.com/kentcdodds/react-testing-library/commits?author=MarkFalconbridge "Code") | [Vinicius
Vinicius](https://github.com/viniciusavieira)
[πŸ“–](https://github.com/kentcdodds/react-testing-library/commits?author=viniciusavieira "Documentation") [πŸ’‘](#example-viniciusavieira "Examples") | + This project follows the [all-contributors][all-contributors] specification. diff --git a/examples/__tests__/react-intl.js b/examples/__tests__/react-intl.js new file mode 100644 index 00000000..48fe0e0f --- /dev/null +++ b/examples/__tests__/react-intl.js @@ -0,0 +1,45 @@ +import React from 'react' +import 'jest-dom/extend-expect' +import {render, cleanup, getByTestId} from 'react-testing-library' +import {IntlProvider, FormattedDate} from 'react-intl' +import IntlPolyfill from 'intl' +import 'intl/locale-data/jsonp/pt' + +const setupTests = () => { + // Test enviroment run as server enviroment and should have polyfill to locale + // https://formatjs.io/guides/runtime-environments/#server + if (global.Intl) { + Intl.NumberFormat = IntlPolyfill.NumberFormat + Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat + } else { + global.Intl = require('intl') + } +} + +const FormatDateView = () => { + return ( +
+ +
+ ) +} + +const renderWithReactIntl = component => { + return { + ...render({component}), + } +} + +setupTests() +afterEach(cleanup) + +test('it should render FormattedDate and have a formated pt date', () => { + const {container} = renderWithReactIntl() + expect(getByTestId(container, 'date-display')).toHaveTextContent('11/03/2019') +}) diff --git a/package.json b/package.json index 54f531f1..8220dcbe 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,13 @@ "axios": "^0.18.0", "eslint-import-resolver-jest": "^2.1.1", "history": "^4.7.2", + "intl": "^1.2.5", "jest-dom": "3.0.1", "jest-in-case": "^1.0.2", "kcd-scripts": "0.49.0", "react": "^16.8.0", "react-dom": "^16.8.0", + "react-intl": "^2.8.0", "react-redux": "6.0.0", "react-router": "^4.3.1", "react-router-dom": "^4.3.1",