Skip to content

Commit

Permalink
Test case rich text support in FormattedMessage function-as-child pat…
Browse files Browse the repository at this point in the history
…tern (formatjs#837)

* Add breaking test case for rich-text in FormattedMessage function-as-child

* Fix the test case rich-text in FormattedMessage function-as-child pattern
  • Loading branch information
p10ns11y authored and ericf committed Feb 1, 2017
1 parent 5d9e389 commit 880270f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/components/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,31 @@ describe('<FormattedMessage>', () => {
<span>Hello, <b>Eric</b>!</span>
);
});

it('supports rich-text message formatting in function-as-child pattern', () => {
const {intl} = intlProvider.getChildContext();

const el = (
<FormattedMessage
id="hello"
defaultMessage="Hello, {name}!"
values={{
name: <b>Prem</b>,
}}
>
{(...formattedMessage) => (
<strong>{formattedMessage}</strong>
)}

</FormattedMessage>
);

renderer.render(el, {intl});
const rendered = renderer.getRenderOutput();

expect(rendered.props.children).toBeAn('array');
expect(rendered).toEqualJSX(
<strong>Hello, <b>Prem</b>!</strong>
);
});
});

0 comments on commit 880270f

Please sign in to comment.