2016-10-02 14:16:22 +00:00
|
|
|
import i18n from '../../website/common/script/i18n';
|
2020-07-01 16:20:18 +00:00
|
|
|
import { translations } from '../../website/server/libs/i18n';
|
2019-10-08 18:45:38 +00:00
|
|
|
|
2020-07-01 16:20:18 +00:00
|
|
|
i18n.translations = translations;
|
2016-10-02 14:16:22 +00:00
|
|
|
|
|
|
|
|
const STRING_ERROR_MSG = 'Error processing the string. Please see Help > Report a Bug.';
|
|
|
|
|
const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
|
2016-01-16 20:09:20 +00:00
|
|
|
|
|
|
|
|
// Use this to verify error messages returned by the server
|
|
|
|
|
// That way, if the translated string changes, the test
|
|
|
|
|
// will not break. NOTE: it checks against errors with string as well.
|
2016-12-16 00:36:54 +00:00
|
|
|
export function translate (key, variables, language) {
|
2019-10-08 18:45:38 +00:00
|
|
|
const translatedString = i18n.t(key, variables, language);
|
2016-01-16 20:09:20 +00:00
|
|
|
|
|
|
|
|
expect(translatedString).to.not.be.empty;
|
|
|
|
|
expect(translatedString).to.not.eql(STRING_ERROR_MSG);
|
|
|
|
|
expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG);
|
|
|
|
|
|
|
|
|
|
return translatedString;
|
|
|
|
|
}
|
2018-03-24 14:57:02 +00:00
|
|
|
|
|
|
|
|
export function translationCheck (translatedString) {
|
|
|
|
|
expect(translatedString).to.not.be.empty;
|
|
|
|
|
expect(translatedString).to.not.eql(STRING_ERROR_MSG);
|
|
|
|
|
expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG);
|
|
|
|
|
}
|