test(curriculum): add localeTitle to the challenge schema (#31598)

This commit is contained in:
Valeriy
2018-10-30 18:48:54 +03:00
committed by mrugesh mohapatra
parent c8219fd0e1
commit 65094d13e4

View File

@ -1,7 +1,11 @@
const Joi = require('joi');
Joi.objectId = require('joi-objectid')(Joi);
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });
const schema = Joi.object().keys({
const { LOCALE: lang = 'english' } = process.env;
let schema = Joi.object().keys({
block: Joi.string(),
blockId: Joi.objectId(),
challengeOrder: Joi.number(),
@ -69,6 +73,12 @@ const schema = Joi.object().keys({
title: Joi.string().required()
});
if (lang !== 'english') {
schema = schema.append({
localeTitle: Joi.string().required()
});
}
exports.validateChallenge = function validateChallenge(challenge) {
return Joi.validate(challenge, schema);
};