Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(translation): allow undefined value to be passed on purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed May 14, 2019
1 parent fba5cdf commit ab81d0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ describe('translatable', () => {
const defaultTranslations = {
sup: 'hey',
thing: n => `${n} things`,
fallbackThing: 'hi',
};
const translations = {
sup: 'hoy',
fallbackThing: undefined,
};
const Translated = translatable(defaultTranslations)(Dummy);
const { translate } = shallow(<Translated translations={translations} />)
.find(Dummy)
.props();
expect(translate('sup')).toBe('hoy');
expect(translate('thing', 20)).toBe('20 things');
expect(translate('fallbackThing')).toBe(undefined);
});
});
2 changes: 1 addition & 1 deletion packages/react-instantsearch-core/src/core/translatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function translatable(defaultTranslations) {
const { translations } = this.props;

const translation =
translations && translations[key] !== undefined
translations && translations.hasOwnProperty(key)
? translations[key]
: defaultTranslations[key];

Expand Down

0 comments on commit ab81d0b

Please sign in to comment.