mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Update tests to assert against translation strings
This commit is contained in:
@@ -7,6 +7,9 @@ import {
|
||||
import {MongoClient as mongo} from 'mongodb';
|
||||
import {v4 as generateUUID} from 'uuid';
|
||||
import superagent from 'superagent';
|
||||
import i18n from '../../common/script/src/i18n';
|
||||
require('coffee-script');
|
||||
i18n.translations = require('../../website/src/i18n.js').translations;
|
||||
|
||||
const API_TEST_SERVER_PORT = 3003;
|
||||
|
||||
@@ -22,6 +25,22 @@ export function requester(user={}) {
|
||||
}
|
||||
};
|
||||
|
||||
// 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 agains 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;
|
||||
};
|
||||
|
||||
// Creates a new user and returns it
|
||||
// If you need the user to have specific requirements,
|
||||
// such as a balance > 0, just pass in the adjustment
|
||||
|
||||
Reference in New Issue
Block a user