habitica/test/helpers/content.helper.js

20 lines
738 B
JavaScript
Raw Normal View History

import i18n from '../../website/common/script/i18n';
2019-10-15 13:32:53 +00:00
import './globals.helper';
import { translations } from '../../website/server/libs/i18n';
2019-10-08 18:45:38 +00:00
2019-10-15 13:32:53 +00:00
i18n.translations = translations;
2015-09-29 12:55:13 +00:00
export const STRING_ERROR_MSG = /^Error processing the string ".*". Please see Help > Report a Bug.$/;
export const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
2015-09-29 12:55:13 +00:00
export function expectValidTranslationString (attribute) {
2015-09-29 12:55:13 +00:00
expect(attribute).to.be.a('function');
2019-10-08 18:45:38 +00:00
const translatedString = attribute();
2015-09-29 12:55:13 +00:00
expect(translatedString.trim()).to.not.be.empty;
expect(translatedString).to.not.contain('function func(lang)');
2015-09-29 12:55:13 +00:00
expect(translatedString).to.not.eql(STRING_ERROR_MSG);
expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG);
}