Skip to content
This repository has been archived by the owner. It is now read-only.

chore(tests): make sure unit tests pass with different locales #4535

Merged
merged 1 commit into from Jan 11, 2017
Merged

Conversation

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Dec 20, 2016

@vladikoff vladikoff self-assigned this Dec 20, 2016
@vladikoff vladikoff requested a review from shane-tomlinson Dec 20, 2016
Copy link
Member

@shane-tomlinson shane-tomlinson left a comment

What if instead of calling a clearTranslationValues function, if we pass an option to the constructor to indicate "use the English values". My preference would be something like:

let translator = new Translator({ lang: 'en_US' });

But that'd imply we could force any language.

Maybe something like:

let translator = new Translator({ forceEnglish: true });

And in the constructor, if forceEnglish === true, set this.__translations = {}

Would that be cleaner?

* @private
*/
_clearTranslationValues () {
Object.keys(this.__translations__).forEach((translationKey) => {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Dec 21, 2016
Member

I think you should be able to just do a this.__translations__ = {}. get will see no translation exists for the key and use the key as the translation.

*
* Useful in tests to avoid failures when
* running tests with a non-EN-US locale.
* @private

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Dec 21, 2016
Member

This function is called outside of this module so isn't really private.

@vladikoff
Copy link
Contributor Author

@vladikoff vladikoff commented Jan 11, 2017

Would that be cleaner?

Yeah, sorry I tried that earlier but translator exploded. works now 👍

@vladikoff vladikoff merged commit 878b80c into master Jan 11, 2017
4 checks passed
4 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.1%) to 98.487%
Details
@vladikoff vladikoff deleted the i4437 branch Jan 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants