Skip to content

Commit

Permalink
Fix regression with custom mapTranslationToProps behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Marrington committed Mar 6, 2018
1 parent 9d950a5 commit 2cd1c9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/translated-components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const translated = ({
locale: props.locale || locale || defaultLocale,
defaultLocale,
reducer: templateReducer(templateParamValues(props, params))
}))}
}), props)}
/>
)
}}
Expand Down
27 changes: 27 additions & 0 deletions packages/translated-components/test/translated-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => <div>{props.one}{props.two}{props.three}</div>
const DummyTranslated = translated({translations, mapTranslationsToProps})(Dummy)
const wrapper = mount(
<LocaleProvider locale='en_NZ' defaultLocale='en_AU'>
<DummyTranslated three='Three' />
</LocaleProvider>
)

assert(wrapper.text().includes('Three Extra info!'))
})
})

0 comments on commit 2cd1c9c

Please sign in to comment.