mirror of https://github.com/zulip/zulip.git
node tests: Actually test `translations.js`.
Before this test, we were validating the behavior of `i18next`, but we weren't validating our light layer that sits on top of `i18next`, which currently resides in the slightly misnamed `translations.js` file. The translations module is now so small that I'll just quote it verbatim here: import i18next from 'i18next'; i18next.init({ lng: 'lang', resources: { lang: { translation: page_params.translation_data, }, }, nsSeparator: false, keySeparator: false, interpolation: { prefix: "__", suffix: "__", }, returnEmptyString: false, // Empty string is not a valid translation. }); window.i18n = i18next; We now just do `zrequire('translations')` to initialize the `i18next` library, which allows us to have simpler test setup and to actually exercise the above call to `i18next.init`. This change now gives us 100% line coverage of `translations.js`, which of course isn't that hard to acheive (see above).
This commit is contained in:
parent
1abd00eac2
commit
e67be55152
|
@ -1,30 +1,23 @@
|
||||||
set_global('Handlebars', global.make_handlebars());
|
set_global('Handlebars', global.make_handlebars());
|
||||||
zrequire('templates');
|
zrequire('templates');
|
||||||
|
|
||||||
// All of our other tests stub out i18n activity;
|
// We download our translations in `page_params` (which
|
||||||
// here we do a quick sanity check on the engine itself.
|
// are for the user's chosen language), so we simulate
|
||||||
const i18next = zrequire('i18next', 'i18next');
|
// that here for the tests.
|
||||||
|
set_global('page_params', {
|
||||||
global.i18n = i18next;
|
translation_data: {
|
||||||
|
|
||||||
i18next.init({
|
|
||||||
nsSeparator: false,
|
|
||||||
keySeparator: false,
|
|
||||||
interpolation: {
|
|
||||||
prefix: "__",
|
|
||||||
suffix: "__",
|
|
||||||
},
|
|
||||||
lng: 'fr',
|
|
||||||
resources: {
|
|
||||||
fr: {
|
|
||||||
translation: {
|
|
||||||
"Quote and reply": "French translation",
|
"Quote and reply": "French translation",
|
||||||
"Desktop notifications are triggered for messages that are offscreen when they arrive. Mobile and email notifications are triggered once you have been away from Zulip for a few minutes.": "Some French text",
|
"Desktop notifications are triggered for messages that are offscreen when they arrive. Mobile and email notifications are triggered once you have been away from Zulip for a few minutes.": "Some French text",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// All of our other tests stub out i18n activity;
|
||||||
|
// here we do a quick sanity check on the engine itself.
|
||||||
|
// We use `translations.js` to initialize `i18next` and
|
||||||
|
// to set `i18n` to `i18next` on the global namespace
|
||||||
|
// for `templates.js`.
|
||||||
|
zrequire('translations');
|
||||||
|
|
||||||
run_test('t_tag', () => {
|
run_test('t_tag', () => {
|
||||||
const args = {
|
const args = {
|
||||||
message: {
|
message: {
|
||||||
|
|
|
@ -146,7 +146,6 @@ EXEMPT_FILES = {
|
||||||
'static/js/todo_widget.js',
|
'static/js/todo_widget.js',
|
||||||
'static/js/topic_list.js',
|
'static/js/topic_list.js',
|
||||||
'static/js/topic_zoom.js',
|
'static/js/topic_zoom.js',
|
||||||
'static/js/translations.js',
|
|
||||||
'static/js/tutorial.js',
|
'static/js/tutorial.js',
|
||||||
'static/js/typing_events.js',
|
'static/js/typing_events.js',
|
||||||
'static/js/typing.js',
|
'static/js/typing.js',
|
||||||
|
|
Loading…
Reference in New Issue