From 2cd1c9ca8c35d61c8aa3267d0279ffafcef189fb Mon Sep 17 00:00:00 2001 From: Justin Marrington Date: Tue, 6 Mar 2018 11:06:28 +1000 Subject: [PATCH] Fix regression with custom `mapTranslationToProps` behaviour --- packages/translated-components/src/index.js | 2 +- .../test/translated-component-test.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/translated-components/src/index.js b/packages/translated-components/src/index.js index cd54465..9f79e81 100644 --- a/packages/translated-components/src/index.js +++ b/packages/translated-components/src/index.js @@ -40,7 +40,7 @@ const translated = ({ locale: props.locale || locale || defaultLocale, defaultLocale, reducer: templateReducer(templateParamValues(props, params)) - }))} + }), props)} /> ) }} diff --git a/packages/translated-components/test/translated-component-test.js b/packages/translated-components/test/translated-component-test.js index c362047..ef5f04e 100644 --- a/packages/translated-components/test/translated-component-test.js +++ b/packages/translated-components/test/translated-component-test.js @@ -210,4 +210,31 @@ describe('Translate', () => { assert(wrapper.text().includes(translations['en_AU'].two)) }) + + it('should execute a custom mapTranslationsToProps to provide interpolated translations, if it exists', () => { + const translations = { + en_AU: { + one: 'AUOne', + two: 'AUTwo' + }, + en_NZ: { + one: 'NZOne' + } + } + const mapTranslationsToProps = (translations, props) => { + return { + ...translations, + three: props.three + ' Extra info!' + } + } + const Dummy = (props) =>
{props.one}{props.two}{props.three}
+ const DummyTranslated = translated({translations, mapTranslationsToProps})(Dummy) + const wrapper = mount( + + + + ) + + assert(wrapper.text().includes('Three Extra info!')) + }) })