Files
habitica/test/helpers/api-integration/translate.js
Matteo Pagliazzi 45c31a2bcf Deprecate API v2 (#7761)
* deprecate api-v2

* remove v2 test helpers

* remove unused string
2016-07-16 19:56:18 +02:00

19 lines
765 B
JavaScript

import i18n from '../../../common/script/i18n';
i18n.translations = require('../../../website/server/libs/i18n').translations;
// 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.
export function translate (key, variables) {
const STRING_ERROR_MSG = 'Error processing the string. Please see Help > Report a Bug.';
const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
let translatedString = i18n.t(key, variables);
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;
}