2020-07-15 01:29:15 +02:00
|
|
|
set_global("Handlebars", global.make_handlebars());
|
|
|
|
zrequire("templates");
|
2016-05-13 12:44:03 +02:00
|
|
|
|
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).
2020-02-29 12:59:56 +01:00
|
|
|
// We download our translations in `page_params` (which
|
|
|
|
// are for the user's chosen language), so we simulate
|
|
|
|
// that here for the tests.
|
2020-07-15 01:29:15 +02:00
|
|
|
set_global("page_params", {
|
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).
2020-02-29 12:59:56 +01:00
|
|
|
translation_data: {
|
|
|
|
"Quote and reply": "French translation",
|
2020-03-26 03:35:57 +01:00
|
|
|
"Notification triggers": "Some French text",
|
2016-12-03 23:17:57 +01:00
|
|
|
},
|
2016-05-13 12:44:03 +02:00
|
|
|
});
|
|
|
|
|
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).
2020-02-29 12:59:56 +01:00
|
|
|
// All of our other tests stub out i18n activity;
|
|
|
|
// here we do a quick sanity check on the engine itself.
|
2020-02-29 13:12:31 +01:00
|
|
|
// We use `i18n.js` to initialize `i18next` and
|
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).
2020-02-29 12:59:56 +01:00
|
|
|
// to set `i18n` to `i18next` on the global namespace
|
|
|
|
// for `templates.js`.
|
2020-07-15 01:29:15 +02:00
|
|
|
zrequire("i18n");
|
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).
2020-02-29 12:59:56 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("t_tag", () => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
message: {
|
2016-05-13 12:44:03 +02:00
|
|
|
is_stream: true,
|
|
|
|
id: "99",
|
|
|
|
stream: "devel",
|
|
|
|
subject: "testing",
|
2016-12-03 23:17:57 +01:00
|
|
|
sender_full_name: "King Lear",
|
2016-05-13 12:44:03 +02:00
|
|
|
},
|
2018-03-28 00:28:57 +02:00
|
|
|
should_display_quote_and_reply: true,
|
2016-12-03 03:08:47 +01:00
|
|
|
can_edit_message: true,
|
|
|
|
can_mute_topic: true,
|
2016-12-03 23:17:57 +01:00
|
|
|
narrowed: true,
|
2016-05-13 12:44:03 +02:00
|
|
|
};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const html = require("../../static/templates/actions_popover_content.hbs")(args);
|
2017-04-04 15:44:45 +02:00
|
|
|
assert(html.indexOf("French translation") > 0);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2016-05-13 12:44:03 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("tr_tag", () => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const args = {
|
2016-12-03 03:08:47 +01:00
|
|
|
page_params: {
|
2017-04-27 00:26:49 +02:00
|
|
|
full_name: "John Doe",
|
2016-12-03 03:08:47 +01:00
|
|
|
password_auth_enabled: false,
|
|
|
|
avatar_url: "http://example.com",
|
|
|
|
left_side_userlist: false,
|
|
|
|
twenty_four_hour_time: false,
|
2017-04-29 07:01:46 +02:00
|
|
|
enable_stream_desktop_notifications: false,
|
2017-08-17 16:55:32 +02:00
|
|
|
enable_stream_push_notifications: false,
|
2019-06-11 08:47:49 +02:00
|
|
|
enable_stream_audible_notifications: false,
|
2017-04-29 08:13:47 +02:00
|
|
|
enable_desktop_notifications: false,
|
2017-04-29 06:53:28 +02:00
|
|
|
enable_sounds: false,
|
2016-12-03 03:08:47 +01:00
|
|
|
enable_offline_email_notifications: false,
|
|
|
|
enable_offline_push_notifications: false,
|
|
|
|
enable_online_push_notifications: false,
|
|
|
|
enable_digest_emails: false,
|
2016-12-03 23:17:57 +01:00
|
|
|
},
|
2016-05-13 12:44:03 +02:00
|
|
|
};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const html = require("../../static/templates/settings_tab.hbs")(args);
|
|
|
|
assert(html.indexOf("Some French text") > 0);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|