Update tests to assert against translation strings

This commit is contained in:
Blade Barringer
2015-10-30 09:01:57 -05:00
parent d3a6ff5b2d
commit aa111b3c1a
21 changed files with 157 additions and 52 deletions

View File

@@ -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