Fix Ludown eslint issues
This commit is contained in:
Родитель
b0ff5f5cbc
Коммит
b812c426ca
|
@ -11,7 +11,7 @@ indent_size=2
|
||||||
|
|
||||||
[*.js.map]
|
[*.js.map]
|
||||||
indent_style=space
|
indent_style=space
|
||||||
indent_size=2
|
indent_size=4
|
||||||
|
|
||||||
[{.analysis_options,*.yml,*.yaml}]
|
[{.analysis_options,*.yml,*.yaml}]
|
||||||
indent_style=space
|
indent_style=space
|
||||||
|
|
|
@ -16,6 +16,6 @@ class LUIS {
|
||||||
this.patternAnyEntities = [];
|
this.patternAnyEntities = [];
|
||||||
this.prebuiltEntities = [];
|
this.prebuiltEntities = [];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = LUIS;
|
module.exports = LUIS;
|
|
@ -24,6 +24,6 @@ class parserObject {
|
||||||
this.qnaJsonStructure = new QnA();
|
this.qnaJsonStructure = new QnA();
|
||||||
this.qnaAlterations = new qnaAlterations.qnaAlterations();
|
this.qnaAlterations = new qnaAlterations.qnaAlterations();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = parserObject;
|
module.exports = parserObject;
|
|
@ -13,6 +13,6 @@ class QnA {
|
||||||
this.urls = urls?urls:[];
|
this.urls = urls?urls:[];
|
||||||
this.qnaList = qnaList?qnaList:[];
|
this.qnaList = qnaList?qnaList:[];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = QnA;
|
module.exports = QnA;
|
|
@ -25,6 +25,6 @@ class qnaList {
|
||||||
this.questions = questions?questions:[];
|
this.questions = questions?questions:[];
|
||||||
this.metadata = metadata?metadata:[];
|
this.metadata = metadata?metadata:[];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = qnaList;
|
module.exports = qnaList;
|
|
@ -13,6 +13,6 @@ class qnaMetaData {
|
||||||
this.name = name?name:'';
|
this.name = name?name:'';
|
||||||
this.value = value?value:'';
|
this.value = value?value:'';
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = qnaMetaData;
|
module.exports = qnaMetaData;
|
|
@ -61,6 +61,7 @@ const helpers = {
|
||||||
let sectionsInFile = [];
|
let sectionsInFile = [];
|
||||||
let currentSectionType = null; //PARSERCONSTS
|
let currentSectionType = null; //PARSERCONSTS
|
||||||
let inQnAAnswer = false;
|
let inQnAAnswer = false;
|
||||||
|
let lineIndex = 0;
|
||||||
for(lineIndex in linesInFile) {
|
for(lineIndex in linesInFile) {
|
||||||
let currentLine = linesInFile[lineIndex].trim();
|
let currentLine = linesInFile[lineIndex].trim();
|
||||||
// QnA answer can be multi-line markdown. So (re)set the in answer flag
|
// QnA answer can be multi-line markdown. So (re)set the in answer flag
|
||||||
|
@ -129,7 +130,6 @@ const helpers = {
|
||||||
if(currentLine.toLowerCase().includes(':')) {
|
if(currentLine.toLowerCase().includes(':')) {
|
||||||
// get entity name and type
|
// get entity name and type
|
||||||
let entityDef = currentLine.replace(PARSERCONSTS.ENTITY, '').split(':');
|
let entityDef = currentLine.replace(PARSERCONSTS.ENTITY, '').split(':');
|
||||||
let entityName = entityDef[0];
|
|
||||||
let entityType = entityDef[1];
|
let entityType = entityDef[1];
|
||||||
// is entityType a phraseList?
|
// is entityType a phraseList?
|
||||||
if(entityType.trim().toLowerCase().includes('phraselist') || entityType.trim().toLowerCase().includes('qna-alterations')) {
|
if(entityType.trim().toLowerCase().includes('phraselist') || entityType.trim().toLowerCase().includes('qna-alterations')) {
|
||||||
|
@ -204,28 +204,28 @@ const helpers = {
|
||||||
var validateAndPushCurrentBuffer = function(previousSection, sectionsInFile, currentSectionType, lineIndex, log) {
|
var validateAndPushCurrentBuffer = function(previousSection, sectionsInFile, currentSectionType, lineIndex, log) {
|
||||||
previousSection = helpers.sanitizeNewLines(previousSection);
|
previousSection = helpers.sanitizeNewLines(previousSection);
|
||||||
switch(currentSectionType) {
|
switch(currentSectionType) {
|
||||||
case PARSERCONSTS.INTENT:
|
case PARSERCONSTS.INTENT:
|
||||||
// warn if there isnt at least one utterance in an intent
|
// warn if there isnt at least one utterance in an intent
|
||||||
if(previousSection.split(NEWLINE).length === 1) {
|
if(previousSection.split(NEWLINE).length === 1) {
|
||||||
++lineIndex;
|
++lineIndex;
|
||||||
if(previousSection.split(NEWLINE)[0].includes('?')) {
|
if(previousSection.split(NEWLINE)[0].includes('?')) {
|
||||||
throw(new exception(retCode.errorCode.INVALID_LINE, 'Line #' + lineIndex + ': [ERR] No answer found for question: ' + previousSection.split(NEWLINE)[0]));
|
throw(new exception(retCode.errorCode.INVALID_LINE, 'Line #' + lineIndex + ': [ERR] No answer found for question: ' + previousSection.split(NEWLINE)[0]));
|
||||||
} else {
|
} else {
|
||||||
if(log) process.stdout.write(chalk.yellow('Line #' + lineIndex + ': [WARN] No utterances found for intent: ' + previousSection.split(NEWLINE)[0] + NEWLINE));
|
if(log) process.stdout.write(chalk.yellow('Line #' + lineIndex + ': [WARN] No utterances found for intent: ' + previousSection.split(NEWLINE)[0] + NEWLINE));
|
||||||
}
|
|
||||||
--lineIndex;
|
|
||||||
}
|
}
|
||||||
sectionsInFile.push(previousSection);
|
--lineIndex;
|
||||||
break;
|
}
|
||||||
case PARSERCONSTS.ENTITY:
|
sectionsInFile.push(previousSection);
|
||||||
// warn if there isnt at least one synonym for a list entity
|
break;
|
||||||
if(previousSection.split(NEWLINE).length === 1) {
|
case PARSERCONSTS.ENTITY:
|
||||||
++lineIndex;
|
// warn if there isnt at least one synonym for a list entity
|
||||||
if(log) process.stdout.write(chalk.yellow('Line #' + lineIndex + ': [WARN] No synonyms list found for list entity:' + previousSection.split(NEWLINE)[0] + NEWLINE));
|
if(previousSection.split(NEWLINE).length === 1) {
|
||||||
--lineIndex;
|
++lineIndex;
|
||||||
}
|
if(log) process.stdout.write(chalk.yellow('Line #' + lineIndex + ': [WARN] No synonyms list found for list entity:' + previousSection.split(NEWLINE)[0] + NEWLINE));
|
||||||
sectionsInFile.push(previousSection);
|
--lineIndex;
|
||||||
break;
|
}
|
||||||
|
sectionsInFile.push(previousSection);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return sectionsInFile;
|
return sectionsInFile;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ const fParser = require('../lib/parser');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
const retCode = require('../lib/enums/CLI-errors');
|
||||||
const cmdEnum = require('../lib/enums/parsecommands');
|
const cmdEnum = require('../lib/enums/parsecommands');
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
program.Command.prototype.unknownOption = function () {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -28,20 +28,20 @@ program
|
||||||
.option('--verbose', '[Optional] Get verbose messages from parser')
|
.option('--verbose', '[Optional] Get verbose messages from parser')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (process.argv.length < 4) {
|
if (process.argv.length < 4) {
|
||||||
|
program.help();
|
||||||
|
} else {
|
||||||
|
if (!program.in && !program.lu_folder) {
|
||||||
|
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
||||||
program.help();
|
program.help();
|
||||||
} else {
|
|
||||||
if (!program.in && !program.lu_folder) {
|
|
||||||
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
|
||||||
program.help();
|
|
||||||
}
|
|
||||||
fParser.handleFile(program, cmdEnum.luis)
|
|
||||||
.then(function(){
|
|
||||||
process.exit(retCode.errorCode.SUCCESS);
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
|
||||||
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
|
||||||
process.exit(err.errCode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
fParser.handleFile(program, cmdEnum.luis)
|
||||||
|
.then(function () {
|
||||||
|
process.exit(retCode.errorCode.SUCCESS);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
||||||
|
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
||||||
|
process.exit(err.errCode);
|
||||||
|
});
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ const fParser = require('../lib/parser');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
const retCode = require('../lib/enums/CLI-errors');
|
||||||
const cmdEnum = require('../lib/enums/parsecommands');
|
const cmdEnum = require('../lib/enums/parsecommands');
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
program.Command.prototype.unknownOption = function () {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -25,20 +25,20 @@ program
|
||||||
.option('--verbose', '[Optional] Get verbose messages from parser')
|
.option('--verbose', '[Optional] Get verbose messages from parser')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (process.argv.length < 4) {
|
if (process.argv.length < 4) {
|
||||||
|
program.help();
|
||||||
|
} else {
|
||||||
|
if (!program.in && !program.lu_folder) {
|
||||||
|
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
||||||
program.help();
|
program.help();
|
||||||
} else {
|
|
||||||
if (!program.in && !program.lu_folder) {
|
|
||||||
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
|
||||||
program.help();
|
|
||||||
}
|
|
||||||
fParser.handleFile(program, cmdEnum.qna)
|
|
||||||
.then(function(){
|
|
||||||
process.exit(retCode.errorCode.SUCCESS);
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
|
||||||
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
|
||||||
process.exit(err.errCode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
fParser.handleFile(program, cmdEnum.qna)
|
||||||
|
.then(function () {
|
||||||
|
process.exit(retCode.errorCode.SUCCESS);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
||||||
|
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
||||||
|
process.exit(err.errCode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
*/
|
*/
|
||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
program.Command.prototype.unknownOption = function () {
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -19,8 +18,8 @@ program
|
||||||
.alias('toqna')
|
.alias('toqna')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
const commands = ['toluis', 'toqna']
|
const commands = ['toluis', 'toqna']
|
||||||
if (!commands.includes(process.argv[2].toLowerCase())) {
|
if (!commands.includes(process.argv[2].toLowerCase())) {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown command: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown command: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ const program = require('commander');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const toLU = require('../lib/toLU');
|
const toLU = require('../lib/toLU');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
const retCode = require('../lib/enums/CLI-errors');
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
program.Command.prototype.unknownOption = function () {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -24,20 +24,20 @@ program
|
||||||
.option('-s, --skip_header', '[Optional] Generate .lu file without the header comment')
|
.option('-s, --skip_header', '[Optional] Generate .lu file without the header comment')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (process.argv.length < 4) {
|
if (process.argv.length < 4) {
|
||||||
|
program.help();
|
||||||
|
} else {
|
||||||
|
if (!program.LUIS_File && !program.QNA_FILE && !program.QNA_ALTERATION_FILE) {
|
||||||
|
process.stderr.write(chalk.default.redBright(`\n No LUIS input file or QnA Maker JSON or QnA Alteration file specified.`));
|
||||||
program.help();
|
program.help();
|
||||||
} else {
|
|
||||||
if (!program.LUIS_File && !program.QNA_FILE && !program.QNA_ALTERATION_FILE) {
|
|
||||||
process.stderr.write(chalk.default.redBright(`\n No LUIS input file or QnA Maker JSON or QnA Alteration file specified.`));
|
|
||||||
program.help();
|
|
||||||
}
|
|
||||||
toLU.generateMarkdown(program)
|
|
||||||
.then(function(){
|
|
||||||
process.exit(retCode.errorCode.SUCCESS);
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
|
||||||
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
|
||||||
process.exit(err.errCode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
toLU.generateMarkdown(program)
|
||||||
|
.then(function () {
|
||||||
|
process.exit(retCode.errorCode.SUCCESS);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
||||||
|
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
||||||
|
process.exit(err.errCode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ const program = require('commander');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const translate = require('../lib/translate');
|
const translate = require('../lib/translate');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
const retCode = require('../lib/enums/CLI-errors');
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
program.Command.prototype.unknownOption = function () {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -28,25 +28,24 @@ program
|
||||||
.option('--verbose', '[Optional] Get verbose messages from parser')
|
.option('--verbose', '[Optional] Get verbose messages from parser')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (!program.in && !program.lu_folder) {
|
if (!program.in && !program.lu_folder) {
|
||||||
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
process.stderr.write(chalk.default.redBright(`\n No .lu file or folder specified.\n`));
|
||||||
program.help();
|
program.help();
|
||||||
}
|
}
|
||||||
if(!program.translate_key) {
|
if (!program.translate_key) {
|
||||||
process.stderr.write(chalk.default.redBright(`\n No translate key provided.\n`));
|
process.stderr.write(chalk.default.redBright(`\n No translate key provided.\n`));
|
||||||
program.help();
|
program.help();
|
||||||
}
|
}
|
||||||
if(!program.to_lang) {
|
if (!program.to_lang) {
|
||||||
process.stderr.write(chalk.default.redBright(`\n No target language provided.\n`));
|
process.stderr.write(chalk.default.redBright(`\n No target language provided.\n`));
|
||||||
program.help();
|
program.help();
|
||||||
}
|
}
|
||||||
translate.translateContent(program)
|
translate.translateContent(program)
|
||||||
.then(function(){
|
.then(function () {
|
||||||
process.exit(retCode.errorCode.SUCCESS);
|
process.exit(retCode.errorCode.SUCCESS);
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function (err) {
|
||||||
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
process.stderr.write(chalk.default.redBright(err.text + '\n'));
|
||||||
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
process.stderr.write(chalk.default.redBright('Stopping further processing. \n'));
|
||||||
process.exit(err.errCode);
|
process.exit(err.errCode);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const pjson = require('../package.json');
|
const pjson = require('../package.json');
|
||||||
const retCode = require('../lib/enums/CLI-errors');
|
|
||||||
program.Command.prototype.unknownOption = function (flag) {
|
program.Command.prototype.unknownOption = function () {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown arguments: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
};
|
};
|
||||||
|
@ -21,8 +21,8 @@ program
|
||||||
.command('translate', 'Translate .lu files')
|
.command('translate', 'Translate .lu files')
|
||||||
.alias('t')
|
.alias('t')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
const commands = ['parse', 'p', 'refresh', 'd', 'translate', 't'];
|
const commands = ['parse', 'p', 'refresh', 'd', 'translate', 't'];
|
||||||
if (!commands.includes(process.argv[2].toLowerCase())) {
|
if (!commands.includes(process.argv[2].toLowerCase())) {
|
||||||
process.stderr.write(chalk.default.redBright(`\n Unknown command: ${process.argv.slice(2).join(' ')}\n`));
|
process.stderr.write(chalk.default.redBright(`\n Unknown command: ${process.argv.slice(2).join(' ')}\n`));
|
||||||
program.help();
|
program.help();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ const helperClass = require('./classes/hclasses');
|
||||||
const deepEqual = require('deep-equal');
|
const deepEqual = require('deep-equal');
|
||||||
const qna = require('./classes/qna');
|
const qna = require('./classes/qna');
|
||||||
const exception = require('./classes/exception');
|
const exception = require('./classes/exception');
|
||||||
const LUIS = require('./classes/LUIS');
|
|
||||||
const qnaAlterations = require('./classes/qnaAlterations');
|
const qnaAlterations = require('./classes/qnaAlterations');
|
||||||
const NEWLINE = require('os').EOL;
|
const NEWLINE = require('os').EOL;
|
||||||
const parseFileContentsModule = {
|
const parseFileContentsModule = {
|
||||||
|
@ -246,7 +245,7 @@ const parseFileContentsModule = {
|
||||||
if(blob.prebuiltEntities.length > 0) {
|
if(blob.prebuiltEntities.length > 0) {
|
||||||
blob.prebuiltEntities.forEach(function(prebuiltEntity){
|
blob.prebuiltEntities.forEach(function(prebuiltEntity){
|
||||||
let prebuiltTypeExists = false;
|
let prebuiltTypeExists = false;
|
||||||
for(fIndex in FinalLUISJSON.prebuiltEntities) {
|
for(let fIndex in FinalLUISJSON.prebuiltEntities) {
|
||||||
if(prebuiltEntity.type === FinalLUISJSON.prebuiltEntities[fIndex].type) {
|
if(prebuiltEntity.type === FinalLUISJSON.prebuiltEntities[fIndex].type) {
|
||||||
// do we have all the roles? if not, merge the roles
|
// do we have all the roles? if not, merge the roles
|
||||||
prebuiltEntity.roles.forEach(function(role) {
|
prebuiltEntity.roles.forEach(function(role) {
|
||||||
|
@ -319,7 +318,7 @@ const mergeResults = function(blob, finalCollection, type) {
|
||||||
}
|
}
|
||||||
// add if this item if it does not already exist in final collection
|
// add if this item if it does not already exist in final collection
|
||||||
let itemExists = false;
|
let itemExists = false;
|
||||||
for(fIndex in finalCollection[type]) {
|
for(let fIndex in finalCollection[type]) {
|
||||||
if(deepEqual(finalCollection[type][fIndex],blobItem)){
|
if(deepEqual(finalCollection[type][fIndex],blobItem)){
|
||||||
itemExists = true;
|
itemExists = true;
|
||||||
break;
|
break;
|
||||||
|
@ -635,13 +634,13 @@ const parseAndHandleIntent = function(parsedContent, chunkSplitByLine) {
|
||||||
if((utterance.indexOf('-') !== 0) &&
|
if((utterance.indexOf('-') !== 0) &&
|
||||||
(utterance.indexOf('*') !== 0) &&
|
(utterance.indexOf('*') !== 0) &&
|
||||||
(utterance.indexOf('+') !== 0)) {
|
(utterance.indexOf('+') !== 0)) {
|
||||||
throw ({
|
throw ({
|
||||||
errCode: retCode.errorCode.INVALID_UTTERANCE_DEF,
|
errCode: retCode.errorCode.INVALID_UTTERANCE_DEF,
|
||||||
text: 'Utterance: "' + utterance + '" does not have list decoration. Prefix line with "-" or "+" or "*"'
|
text: 'Utterance: "' + utterance + '" does not have list decoration. Prefix line with "-" or "+" or "*"'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
utterance = utterance.slice(1).trim();
|
utterance = utterance.slice(1).trim();
|
||||||
// handle entities in the utterance
|
// handle entities in the utterance
|
||||||
if(utterance.includes("{")) {
|
if(utterance.includes("{")) {
|
||||||
let entityRegex = new RegExp(/\{(.*?)\}/g);
|
let entityRegex = new RegExp(/\{(.*?)\}/g);
|
||||||
let entitiesFound = utterance.match(entityRegex);
|
let entitiesFound = utterance.match(entityRegex);
|
||||||
|
@ -739,33 +738,34 @@ const parseAndHandleIntent = function(parsedContent, chunkSplitByLine) {
|
||||||
const parseURLOrFileRef = function(parsedContent, type, chunkSplitByLine) {
|
const parseURLOrFileRef = function(parsedContent, type, chunkSplitByLine) {
|
||||||
let urlRef_regex = chunkSplitByLine[0].trim().replace(type, '').split(/\(['"](.*?)['"]\)/g);
|
let urlRef_regex = chunkSplitByLine[0].trim().replace(type, '').split(/\(['"](.*?)['"]\)/g);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case PARSERCONSTS.URLREF:
|
case PARSERCONSTS.URLREF:
|
||||||
if(urlRef_regex.length !== 3 || urlRef_regex[1].trim() === '') {
|
if(urlRef_regex.length !== 3 || urlRef_regex[1].trim() === '') {
|
||||||
throw(new exception(retCode.errorCode.INVALID_URL_REF, '[ERROR]: ' + 'Invalid URL Ref: ' + chunkSplitByLine[0]));
|
throw(new exception(retCode.errorCode.INVALID_URL_REF, '[ERROR]: ' + 'Invalid URL Ref: ' + chunkSplitByLine[0]));
|
||||||
}
|
}
|
||||||
parsedContent.qnaJsonStructure.urls.push(urlRef_regex[1]);
|
parsedContent.qnaJsonStructure.urls.push(urlRef_regex[1]);
|
||||||
break;
|
break;
|
||||||
case PARSERCONSTS.FILEREF:
|
case PARSERCONSTS.FILEREF:
|
||||||
if(urlRef_regex.length !== 3 || urlRef_regex[1].trim() === '') {
|
if(urlRef_regex.length !== 3 || urlRef_regex[1].trim() === '') {
|
||||||
throw(new exception(retCode.errorCode.INVALID_LU_FILE_REF, '[ERROR]: ' + 'Invalid LU File Ref: ' + chunkSplitByLine[0]));
|
throw(new exception(retCode.errorCode.INVALID_LU_FILE_REF, '[ERROR]: ' + 'Invalid LU File Ref: ' + chunkSplitByLine[0]));
|
||||||
}
|
}
|
||||||
parsedContent.additionalFilesToParse.push(urlRef_regex[1]);
|
parsedContent.additionalFilesToParse.push(urlRef_regex[1]);
|
||||||
break;
|
break;
|
||||||
case PARSERCONSTS.URLORFILEREF:
|
case PARSERCONSTS.URLORFILEREF: {
|
||||||
let linkValueRegEx = new RegExp(/\(.*?\)/g);
|
let linkValueRegEx = new RegExp(/\(.*?\)/g);
|
||||||
let linkValueList = chunkSplitByLine[0].trim().match(linkValueRegEx);
|
let linkValueList = chunkSplitByLine[0].trim().match(linkValueRegEx);
|
||||||
let linkValue = linkValueList[0].replace('(','').replace(')','');
|
let linkValue = linkValueList[0].replace('(', '').replace(')', '');
|
||||||
if(linkValue === '') {
|
if (linkValue === '') {
|
||||||
throw(new exception(retCode.errorCode.INVALID_LU_FILE_REF, '[ERROR]: Invalid LU File Ref: ' + chunkSplitByLine[0]));
|
throw (new exception(retCode.errorCode.INVALID_LU_FILE_REF, '[ERROR]: Invalid LU File Ref: ' + chunkSplitByLine[0]));
|
||||||
}
|
}
|
||||||
let parseUrl = url.parse(linkValue);
|
let parseUrl = url.parse(linkValue);
|
||||||
if (parseUrl.host || parseUrl.hostname) {
|
if (parseUrl.host || parseUrl.hostname) {
|
||||||
parsedContent.qnaJsonStructure.urls.push(linkValue);
|
parsedContent.qnaJsonStructure.urls.push(linkValue);
|
||||||
} else {
|
} else {
|
||||||
parsedContent.additionalFilesToParse.push(linkValue);
|
parsedContent.additionalFilesToParse.push(linkValue);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Helper function to add an item to collection if it does not exist
|
* Helper function to add an item to collection if it does not exist
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License.
|
* Licensed under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
/*eslint no-console: ["error", { allow: ["log"] }] */
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
|
|
|
@ -31,7 +31,7 @@ const translateHelpers = {
|
||||||
let currentSectionType = '';
|
let currentSectionType = '';
|
||||||
let data = '';
|
let data = '';
|
||||||
let lText = '';
|
let lText = '';
|
||||||
for(lineIndex in linesInFile) {
|
for(let lineIndex in linesInFile) {
|
||||||
let currentLine = linesInFile[lineIndex].trim();
|
let currentLine = linesInFile[lineIndex].trim();
|
||||||
// is current line a comment?
|
// is current line a comment?
|
||||||
if(currentLine.indexOf(PARSERCONSTS.COMMENT) === 0) {
|
if(currentLine.indexOf(PARSERCONSTS.COMMENT) === 0) {
|
||||||
|
@ -74,118 +74,119 @@ const translateHelpers = {
|
||||||
currentLine.indexOf('+') === 0 ) {
|
currentLine.indexOf('+') === 0 ) {
|
||||||
let listSeparator = '';
|
let listSeparator = '';
|
||||||
let content = '';
|
let content = '';
|
||||||
switch(currentSectionType) {
|
switch (currentSectionType) {
|
||||||
case PARSERCONSTS.INTENT:
|
case PARSERCONSTS.INTENT: {
|
||||||
// strip line of the list separator
|
// strip line of the list separator
|
||||||
listSeparator = currentLine.charAt(0);
|
listSeparator = currentLine.charAt(0);
|
||||||
content = currentLine.slice(1).trim();
|
content = currentLine.slice(1).trim();
|
||||||
let entitiesList = [];
|
let entitiesList = [];
|
||||||
|
|
||||||
// strip line off labelled entity values,mark pattern any entities as not to localize
|
// strip line off labelled entity values,mark pattern any entities as not to localize
|
||||||
if(content.includes('{')) {
|
if (content.includes('{')) {
|
||||||
const entityRegex = new RegExp(/\{(.*?)\}/g);
|
const entityRegex = new RegExp(/\{(.*?)\}/g);
|
||||||
let entitiesFound = content.match(entityRegex);
|
let entitiesFound = content.match(entityRegex);
|
||||||
let eStartIndex = -1;
|
let eStartIndex = -1;
|
||||||
let eEndIndex = -1;
|
let eEndIndex = -1;
|
||||||
entitiesFound.forEach(function(entity) {
|
entitiesFound.forEach(function (entity) {
|
||||||
let lEntity = entity.replace('{', '').replace('}', '');
|
let lEntity = entity.replace('{', '').replace('}', '');
|
||||||
let labelledValue = '';
|
let labelledValue = '';
|
||||||
// is this a labelled value?
|
// is this a labelled value?
|
||||||
if(lEntity.includes('=')) {
|
if (lEntity.includes('=')) {
|
||||||
let entitySplit = lEntity.split('=');
|
let entitySplit = lEntity.split('=');
|
||||||
if(entitySplit.length > 2) {
|
if (entitySplit.length > 2) {
|
||||||
throw(new exception(retCode.errorCode.INVALID_INPUT, '[ERROR]: Nested entity references are not supported in utterance: ' + content));
|
throw (new exception(retCode.errorCode.INVALID_INPUT, '[ERROR]: Nested entity references are not supported in utterance: ' + content));
|
||||||
|
}
|
||||||
|
lEntity = entitySplit[0].trim();
|
||||||
|
labelledValue = entitySplit[1].trim();
|
||||||
|
if (!labelledValue.includes(' ')) {
|
||||||
|
let updatedUtteranceLeft = content.substring(0, content.indexOf(entity));
|
||||||
|
let updatedUtteranceRight = content.substring(content.indexOf(entity) + entity.length);
|
||||||
|
content = updatedUtteranceLeft + labelledValue + updatedUtteranceRight;
|
||||||
|
eStartIndex = content.indexOf(labelledValue);
|
||||||
|
eEndIndex = eStartIndex + labelledValue.length - 1;
|
||||||
|
entitiesList.push(new helperClasses.entity(lEntity, labelledValue, eStartIndex, eEndIndex));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eStartIndex = content.indexOf(lEntity);
|
||||||
|
eEndIndex = eStartIndex + lEntity.length - 1;
|
||||||
|
entitiesList.push(new helperClasses.entity(lEntity, labelledValue, eStartIndex, eEndIndex));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
||||||
|
} catch (err) {
|
||||||
|
throw (err);
|
||||||
|
}
|
||||||
|
if (entitiesList.length === 0) {
|
||||||
|
localizedContent += listSeparator + ' ' + data[0].translations[0].text + NEWLINE;
|
||||||
|
if (log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + data[0].translations[0].text + NEWLINE));
|
||||||
|
} else {
|
||||||
|
// handle alignment
|
||||||
|
lText = data[0].translations[0].text;
|
||||||
|
if (data[0].translations[0].alignment) {
|
||||||
|
let alData = data[0].translations[0].alignment.proj.split(' ');
|
||||||
|
entitiesList.forEach(function (entity) {
|
||||||
|
let testIndex = entity.start + ':' + entity.end;
|
||||||
|
let alDataMap = alData.filter(val => {
|
||||||
|
let p = val.split('-');
|
||||||
|
if (p[0] === testIndex) return p[1];
|
||||||
|
});
|
||||||
|
if (alDataMap.length !== 0) {
|
||||||
|
let seIndex = alDataMap[0].split('-')[1].split(':');
|
||||||
|
let leftText = lText.substring(0, seIndex[0]);
|
||||||
|
let rightText = lText.substring(parseInt(seIndex[1]) + 1);
|
||||||
|
if (entity.value === '') {
|
||||||
|
// we have a pattern any entity
|
||||||
|
lText = leftText + entity.entity + rightText;
|
||||||
|
} else {
|
||||||
|
let locLabelledValue = lText.substring(seIndex[0], parseInt(seIndex[1]) + 1);
|
||||||
|
lText = leftText + '{' + entity.entity + '=' + locLabelledValue + '}' + rightText
|
||||||
}
|
}
|
||||||
lEntity = entitySplit[0].trim();
|
|
||||||
labelledValue = entitySplit[1].trim();
|
|
||||||
if(!labelledValue.includes(' ')) {
|
|
||||||
updatedUtteranceLeft = content.substring(0,content.indexOf(entity));
|
|
||||||
updatedUtteranceRight = content.substring(content.indexOf(entity) + entity.length);
|
|
||||||
content = updatedUtteranceLeft + labelledValue + updatedUtteranceRight;
|
|
||||||
eStartIndex = content.indexOf(labelledValue);
|
|
||||||
eEndIndex = eStartIndex + labelledValue.length - 1;
|
|
||||||
entitiesList.push(new helperClasses.entity(lEntity, labelledValue, eStartIndex, eEndIndex));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
eStartIndex = content.indexOf(lEntity);
|
|
||||||
eEndIndex = eStartIndex + lEntity.length - 1;
|
|
||||||
entitiesList.push(new helperClasses.entity(lEntity, labelledValue, eStartIndex, eEndIndex));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
try {
|
|
||||||
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
|
||||||
} catch (err) {
|
|
||||||
throw(err);
|
|
||||||
}
|
|
||||||
if(entitiesList.length === 0) {
|
|
||||||
localizedContent += listSeparator + ' ' + data[0].translations[0].text + NEWLINE;
|
|
||||||
if(log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + data[0].translations[0].text + NEWLINE));
|
|
||||||
} else {
|
} else {
|
||||||
// handle alignment
|
try {
|
||||||
lText = data[0].translations[0].text;
|
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
||||||
if(data[0].translations[0].alignment) {
|
} catch (err) {
|
||||||
let alData = data[0].translations[0].alignment.proj.split(' ');
|
throw (err);
|
||||||
entitiesList.forEach(function(entity) {
|
|
||||||
let testIndex = entity.start + ':' + entity.end;
|
|
||||||
let alDataMap = alData.filter(val => {
|
|
||||||
let p = val.split('-');
|
|
||||||
if(p[0] === testIndex) return p[1];
|
|
||||||
});
|
|
||||||
if(alDataMap.length !== 0) {
|
|
||||||
let seIndex = alDataMap[0].split('-')[1].split(':');
|
|
||||||
let leftText = lText.substring(0, seIndex[0]);
|
|
||||||
let rightText = lText.substring(parseInt(seIndex[1]) + 1);
|
|
||||||
if(entity.value === '') {
|
|
||||||
// we have a pattern any entity
|
|
||||||
lText = leftText + entity.entity + rightText;
|
|
||||||
} else {
|
|
||||||
locLabelledValue = lText.substring(seIndex[0], parseInt(seIndex[1]) + 1);
|
|
||||||
lText = leftText + '{' + entity.entity + '=' + locLabelledValue + '}' + rightText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
|
||||||
} catch (err) {
|
|
||||||
throw(err);
|
|
||||||
}
|
|
||||||
lText = data[0].translations[0].text;
|
|
||||||
}
|
}
|
||||||
|
lText = data[0].translations[0].text;
|
||||||
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
|
||||||
if(log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case PARSERCONSTS.ENTITY:
|
|
||||||
// strip line of the list separator
|
|
||||||
listSeparator = currentLine.charAt(0);
|
|
||||||
content = currentLine.slice(1).trim();
|
|
||||||
try {
|
|
||||||
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
|
||||||
} catch (err) {
|
|
||||||
throw(err);
|
|
||||||
}
|
|
||||||
lText = data[0].translations[0].text;
|
|
||||||
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
||||||
if(log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
if (log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
||||||
break;
|
|
||||||
case PARSERCONSTS.QNA:
|
}
|
||||||
default:
|
break;
|
||||||
// strip line of the list separator
|
}
|
||||||
listSeparator = currentLine.charAt(0);
|
case PARSERCONSTS.ENTITY:
|
||||||
content = currentLine.slice(1).trim();
|
// strip line of the list separator
|
||||||
try {
|
listSeparator = currentLine.charAt(0);
|
||||||
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
content = currentLine.slice(1).trim();
|
||||||
} catch (err) {
|
try {
|
||||||
throw(err);
|
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
||||||
}
|
} catch (err) {
|
||||||
lText = data[0].translations[0].text;
|
throw (err);
|
||||||
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
}
|
||||||
if(log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
lText = data[0].translations[0].text;
|
||||||
break;
|
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
||||||
|
if (log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
||||||
|
break;
|
||||||
|
case PARSERCONSTS.QNA:
|
||||||
|
default:
|
||||||
|
// strip line of the list separator
|
||||||
|
listSeparator = currentLine.charAt(0);
|
||||||
|
content = currentLine.slice(1).trim();
|
||||||
|
try {
|
||||||
|
data = await translateHelpers.translateText(content, subscriptionKey, to_lang, src_lang);
|
||||||
|
} catch (err) {
|
||||||
|
throw (err);
|
||||||
|
}
|
||||||
|
lText = data[0].translations[0].text;
|
||||||
|
localizedContent += listSeparator + ' ' + lText + NEWLINE;
|
||||||
|
if (log) process.stdout.write(chalk.default.gray(listSeparator + ' ' + lText + NEWLINE));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if(currentLine.indexOf(PARSERCONSTS.ENTITY) === 0) {
|
} else if(currentLine.indexOf(PARSERCONSTS.ENTITY) === 0) {
|
||||||
// we need to localize qna alterations if specified.
|
// we need to localize qna alterations if specified.
|
||||||
|
@ -270,9 +271,9 @@ const translateHelpers = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify ([{'Text' : text}]),
|
body: JSON.stringify ([{'Text' : text}]),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Ocp-Apim-Subscription-Key' : subscriptionKey,
|
'Ocp-Apim-Subscription-Key' : subscriptionKey,
|
||||||
'X-ClientTraceId' : get_guid (),
|
'X-ClientTraceId' : get_guid (),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const res = await fetch(tUri, options);
|
const res = await fetch(tUri, options);
|
||||||
|
@ -290,8 +291,8 @@ const translateHelpers = {
|
||||||
*/
|
*/
|
||||||
const get_guid = function () {
|
const get_guid = function () {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,6 @@ describe('Testing all classes', function() {
|
||||||
assert.equal(new exception(testData).text, '');
|
assert.equal(new exception(testData).text, '');
|
||||||
});
|
});
|
||||||
it('can create a new instance from no values passed in as args', function() {
|
it('can create a new instance from no values passed in as args', function() {
|
||||||
let testData = {
|
|
||||||
text: 'foo',
|
|
||||||
errCode: 21
|
|
||||||
};
|
|
||||||
assert.equal(new exception().text, '');
|
assert.equal(new exception().text, '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('The ludown cli tool', function() {
|
||||||
|
|
||||||
describe('with no command', function() {
|
describe('with no command', function() {
|
||||||
it('should print the help contents when --help is passed as an argument', function(done) {
|
it('should print the help contents when --help is passed as an argument', function(done) {
|
||||||
exec(`node ${ludown} --help`, (error, stdout, stderr) => {
|
exec(`node ${ludown} --help`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(stdout.includes('-v'), true);
|
assert.equal(stdout.includes('-v'), true);
|
||||||
done();
|
done();
|
||||||
|
@ -30,7 +30,7 @@ describe('The ludown cli tool', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print the help contents no arguments are passed', function(done) {
|
it('should print the help contents no arguments are passed', function(done) {
|
||||||
exec(`node ${ludown}`, (error, stdout, stderr) => {
|
exec(`node ${ludown}`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(stdout.includes('-v'), true);
|
assert.equal(stdout.includes('-v'), true);
|
||||||
done();
|
done();
|
||||||
|
@ -210,7 +210,7 @@ describe('The ludown cli tool', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show help when root file is missing', function(done) {
|
it('should show help when root file is missing', function(done) {
|
||||||
exec(`node ${ludown} parse toluis`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(stdout.includes('Usage: ludown parse ToLuis --in <luFile>'),true);
|
assert.equal(stdout.includes('Usage: ludown parse ToLuis --in <luFile>'),true);
|
||||||
done();
|
done();
|
||||||
|
@ -298,7 +298,7 @@ describe('The ludown cli tool', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show help when root file is missing', function(done) {
|
it('should show help when root file is missing', function(done) {
|
||||||
exec(`node ${ludown} parse toqna`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(stdout.includes('ludown parse ToQna --in <luFile>'), true);
|
assert.equal(stdout.includes('ludown parse ToQna --in <luFile>'), true);
|
||||||
done();
|
done();
|
||||||
|
@ -377,7 +377,7 @@ describe('The ludown cli tool', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show help when root file is missing', function(done) {
|
it('should show help when root file is missing', function(done) {
|
||||||
exec(`node ${ludown} refresh`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(stdout.includes('Usage: ludown refresh -i <LUISJsonFile>'), true);
|
assert.equal(stdout.includes('Usage: ludown refresh -i <LUISJsonFile>'), true);
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -12,53 +12,53 @@ var inputFileContent = `> Definition for greeting intent
|
||||||
> users might say these
|
> users might say these
|
||||||
- Good morning
|
- Good morning
|
||||||
- Good evening`;
|
- Good evening`;
|
||||||
var outputBlob =
|
var outputBlob =
|
||||||
{
|
{
|
||||||
"intents": [
|
"intents": [
|
||||||
{
|
{
|
||||||
"name": "Greeting"
|
"name": "Greeting"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"entities": [],
|
"entities": [],
|
||||||
"composites": [],
|
"composites": [],
|
||||||
"closedLists": [],
|
"closedLists": [],
|
||||||
"regex_entities": [],
|
"regex_entities": [],
|
||||||
"model_features": [],
|
"model_features": [],
|
||||||
"regex_features": [],
|
"regex_features": [],
|
||||||
"utterances": [
|
"utterances": [
|
||||||
{
|
{
|
||||||
"text": "Hi",
|
"text": "Hi",
|
||||||
"intent": "Greeting",
|
"intent": "Greeting",
|
||||||
"entities": []
|
"entities": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Hello",
|
"text": "Hello",
|
||||||
"intent": "Greeting",
|
"intent": "Greeting",
|
||||||
"entities": []
|
"entities": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Good morning",
|
"text": "Good morning",
|
||||||
"intent": "Greeting",
|
"intent": "Greeting",
|
||||||
"entities": []
|
"entities": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Good evening",
|
"text": "Good evening",
|
||||||
"intent": "Greeting",
|
"intent": "Greeting",
|
||||||
"entities": []
|
"entities": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"patterns": [],
|
"patterns": [],
|
||||||
"patternAnyEntities": [],
|
"patternAnyEntities": [],
|
||||||
"prebuiltEntities": [],
|
"prebuiltEntities": [],
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Comment blocks in .lu files', function() {
|
describe('Comment blocks in .lu files', function() {
|
||||||
it('should be parsed correctly with 1 intent and comments specified', function(done) {
|
it('should be parsed correctly with 1 intent and comments specified', function(done) {
|
||||||
parseFileContents.parseFile(inputFileContent, false, 'en-us')
|
parseFileContents.parseFile(inputFileContent, false, 'en-us')
|
||||||
.then(function(parsedContent){
|
.then(function(parsedContent){
|
||||||
assert.deepEqual(parsedContent.LUISJsonStructure, outputBlob);
|
assert.deepEqual(parsedContent.LUISJsonStructure, outputBlob);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License.
|
* Licensed under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
/*eslint no-console: ["error", { allow: ["log"] }] */
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var assert = chai.assert;
|
var assert = chai.assert;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
@ -15,29 +16,29 @@ const PATH_TO_OUTPUT_FOLDER = path.resolve(TEST_ROOT + '/output');
|
||||||
|
|
||||||
function compareFiles(actualPath, expectedPath) {
|
function compareFiles(actualPath, expectedPath) {
|
||||||
let expected = txtfile.readSync(actualPath).split(/\r?\n/);
|
let expected = txtfile.readSync(actualPath).split(/\r?\n/);
|
||||||
let actual = txtfile.readSync(expectedPath).split(/\r?\n/);;
|
let actual = txtfile.readSync(expectedPath).split(/\r?\n/);
|
||||||
assert.deepEqual(actual, expected);
|
assert.deepEqual(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeExampleJson(fileContent) {
|
function sanitizeExampleJson(fileContent) {
|
||||||
let escapedExampleNewLine = JSON.stringify('\r\n').replace(/\"/g, '').replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
let escapedExampleNewLine = JSON.stringify('\r\n').replace(/"/g, '').replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||||
let escapedNewLine = JSON.stringify(NEWLINE).replace(/\"/g, '');
|
let escapedNewLine = JSON.stringify(NEWLINE).replace(/"/g, '');
|
||||||
return fileContent.replace(new RegExp(escapedExampleNewLine, 'g'), escapedNewLine);
|
return fileContent.replace(new RegExp(escapedExampleNewLine, 'g'), escapedNewLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('The example lu files', function() {
|
describe('The example lu files', function() {
|
||||||
before(function(){
|
before(function () {
|
||||||
try {
|
try {
|
||||||
if(!fs.existsSync(PATH_TO_OUTPUT_FOLDER)) {
|
if (!fs.existsSync(PATH_TO_OUTPUT_FOLDER)) {
|
||||||
fs.mkdirSync(PATH_TO_OUTPUT_FOLDER);
|
fs.mkdirSync(PATH_TO_OUTPUT_FOLDER);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Unable to create test\\output folder. The tests will fail');
|
console.log('Unable to create test\\output folder. The tests will fail');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('refresh command successfully reconstructs a markdown file from a QnA input file with qnaDocuments section', function(done) {
|
it('refresh command successfully reconstructs a markdown file from a QnA input file with qnaDocuments section', function(done) {
|
||||||
exec(`node ${ludown} refresh -q ${TEST_ROOT}/testcases/qnaDocuments.json -o ${TEST_ROOT}/output -n qnaDocuments`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -q ${TEST_ROOT}/testcases/qnaDocuments.json -o ${TEST_ROOT}/output -n qnaDocuments`, () => {
|
||||||
try {
|
try {
|
||||||
done();
|
done();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
@ -47,7 +48,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('refresh command successfully reconstructs a markdown file from a LUIS input file with out of order entity references', function(done) {
|
it('refresh command successfully reconstructs a markdown file from a LUIS input file with out of order entity references', function(done) {
|
||||||
exec(`node ${ludown} refresh -i ${TEST_ROOT}/testcases/test269-d.json -o ${TEST_ROOT}/output -n test269-d2`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -i ${TEST_ROOT}/testcases/test269-d.json -o ${TEST_ROOT}/output -n test269-d2`, () => {
|
||||||
try {
|
try {
|
||||||
done();
|
done();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
@ -57,7 +58,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('refresh command successfully reconstructs a markdown file from a LUIS input file with out of order entity references', function(done) {
|
it('refresh command successfully reconstructs a markdown file from a LUIS input file with out of order entity references', function(done) {
|
||||||
exec(`node ${ludown} refresh -i ${TEST_ROOT}/testcases/test269-d.json -o ${TEST_ROOT}/output --skip_header -n test269-d`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -i ${TEST_ROOT}/testcases/test269-d.json -o ${TEST_ROOT}/output --skip_header -n test269-d`, () => {
|
||||||
try {
|
try {
|
||||||
compareFiles(TEST_ROOT + '/output/test269-d.lu', TEST_ROOT + '/verified/test269-d.lu');
|
compareFiles(TEST_ROOT + '/output/test269-d.lu', TEST_ROOT + '/verified/test269-d.lu');
|
||||||
done();
|
done();
|
||||||
|
@ -67,11 +68,8 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('refresh command successfully reconstructs a markdown file from a LUIS input file', function(done) {
|
it('refresh command successfully reconstructs a markdown file from a LUIS input file', function(done) {
|
||||||
exec(`node ${ludown} refresh -i ${TEST_ROOT}/verified/all.json -o ${TEST_ROOT}/output --skip_header -n allGen`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -i ${TEST_ROOT}/verified/all.json -o ${TEST_ROOT}/output --skip_header -n allGen`, () => {
|
||||||
try {
|
try {
|
||||||
compareFiles(TEST_ROOT + '/output/allGen.lu', TEST_ROOT + '/verified/allRefresh.lu');
|
compareFiles(TEST_ROOT + '/output/allGen.lu', TEST_ROOT + '/verified/allRefresh.lu');
|
||||||
done();
|
done();
|
||||||
|
@ -81,10 +79,8 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('refresh command successfully reconstructs a markdown file from QnA input file', function(done) {
|
it('refresh command successfully reconstructs a markdown file from QnA input file', function(done) {
|
||||||
exec(`node ${ludown} refresh -q ${TEST_ROOT}/verified/all-qna.json -o ${TEST_ROOT}/output --skip_header -n allGenQnA`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -q ${TEST_ROOT}/verified/all-qna.json -o ${TEST_ROOT}/output --skip_header -n allGenQnA`, () => {
|
||||||
try {
|
try {
|
||||||
compareFiles(TEST_ROOT + '/output/allGenQnA.lu', TEST_ROOT + '/verified/allGenQnA.lu');
|
compareFiles(TEST_ROOT + '/output/allGenQnA.lu', TEST_ROOT + '/verified/allGenQnA.lu');
|
||||||
done();
|
done();
|
||||||
|
@ -96,7 +92,7 @@ describe('The example lu files', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('refresh command successfully writes out a markdown file from QnA and luis input files', function(done) {
|
it('refresh command successfully writes out a markdown file from QnA and luis input files', function(done) {
|
||||||
exec(`node ${ludown} refresh -q ${TEST_ROOT}/verified/all-qna.json -i ${TEST_ROOT}/verified/all.json -o ${TEST_ROOT}/output --skip_header --verbose`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -q ${TEST_ROOT}/verified/all-qna.json -i ${TEST_ROOT}/verified/all.json -o ${TEST_ROOT}/output --skip_header --verbose`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
compareFiles(TEST_ROOT + '/output/allall-qna.lu', TEST_ROOT + '/verified/allall-qna.lu');
|
compareFiles(TEST_ROOT + '/output/allall-qna.lu', TEST_ROOT + '/verified/allall-qna.lu');
|
||||||
assert.ok(stdout.includes('Successfully wrote to '));
|
assert.ok(stdout.includes('Successfully wrote to '));
|
||||||
|
@ -109,7 +105,7 @@ describe('The example lu files', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Simple intent and utterances are parsed correctly', function(done) {
|
it('Simple intent and utterances are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/1.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/1.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/1.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/1.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/1.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/1.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -120,10 +116,8 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it('Multiple intent and utterance definition sections are parsed correctly', function(done) {
|
it('Multiple intent and utterance definition sections are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/3.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/3.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/3.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/3.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/3.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/3.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -135,7 +129,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Uttearnces with labelled values are parsed correctly', function(done) {
|
it('Uttearnces with labelled values are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/4.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/4.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/4.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/4.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/4.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/4.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -147,7 +141,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Simple entity declaration is parsed correctly', function(done) {
|
it('Simple entity declaration is parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/5.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/5.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/5.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/5.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/5.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/5.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -159,7 +153,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Prebuilt entity types are parsed correctly', function(done) {
|
it('Prebuilt entity types are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/6.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/6.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/6.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/6.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/6.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/6.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -171,7 +165,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Pattern.any entity types are parsed correctly', function(done) {
|
it('Pattern.any entity types are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/7.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/7.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/7.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/7.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/7.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/7.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -183,7 +177,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('List entity types are parsed correctly', function(done) {
|
it('List entity types are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/9.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/9.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/9.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/9.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/9.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/9.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -195,7 +189,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('List entity definitions and intent definitions can be split up and will be parsed correctly', function(done) {
|
it('List entity definitions and intent definitions can be split up and will be parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/9a.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/9a.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/9a.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/9a.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/9a.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/9a.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -207,7 +201,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with single file references are parsed correctly', function(done) {
|
it('with single file references are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/buyChocolate.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/buyChocolate.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/buyChocolate.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/buyChocolate.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/buyChocolate.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/buyChocolate.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -219,7 +213,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with multiple file references are parsed correctly', function(done) {
|
it('with multiple file references are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/11.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/11.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/11.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/11.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/11.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/11.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -231,7 +225,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with mix of LUIS and QnA content is parsed correctly [LUIS]', function(done) {
|
it('with mix of LUIS and QnA content is parsed correctly [LUIS]', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/12.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/12.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/12.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/12.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/12.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/12.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -243,7 +237,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with mix of LUIS and QnA content is parsed correctly [QnA]', function(done) {
|
it('with mix of LUIS and QnA content is parsed correctly [QnA]', function(done) {
|
||||||
exec(`node ${ludown} parse toqna --in ${TEST_ROOT}/../examples/12.lu -o ${TEST_ROOT}/output -n 12qna`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna --in ${TEST_ROOT}/../examples/12.lu -o ${TEST_ROOT}/output -n 12qna`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/12qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/12qna.json'))));
|
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/12qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/12qna.json'))));
|
||||||
done();
|
done();
|
||||||
|
@ -255,7 +249,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('all concepts of lu file definition is parsed correctly [LUIS]', function(done) {
|
it('all concepts of lu file definition is parsed correctly [LUIS]', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/all.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/../examples/all.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/all.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/all.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/all.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/all.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -267,7 +261,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('all concepts of lu file definition is parsed correctly [QnA]', function(done) {
|
it('all concepts of lu file definition is parsed correctly [QnA]', function(done) {
|
||||||
exec(`node ${ludown} parse toqna --in ${TEST_ROOT}/../examples/all.lu -o ${TEST_ROOT}/output -n all-qna`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna --in ${TEST_ROOT}/../examples/all.lu -o ${TEST_ROOT}/output -n all-qna`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/all-qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/all-qna.json'))));
|
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/all-qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/all-qna.json'))));
|
||||||
done();
|
done();
|
||||||
|
@ -279,7 +273,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('all entity types are parsed correctly', function(done) {
|
it('all entity types are parsed correctly', function(done) {
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/all-entity-types.lu -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/all-entity-types.lu -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/all-entity-types.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/all-entity-types.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/all-entity-types.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/output/all-entity-types.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -291,7 +285,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('writes out a warning when no utterances are found for an intent', function(done){
|
it('writes out a warning when no utterances are found for an intent', function(done){
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/missing-utterance.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/missing-utterance.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.ok(stdout.includes('[WARN] No utterances found for intent: # Greeting'));
|
assert.ok(stdout.includes('[WARN] No utterances found for intent: # Greeting'));
|
||||||
done();
|
done();
|
||||||
|
@ -313,7 +307,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('writes out a warning when no synonym definitions are found for a list entity', function(done){
|
it('writes out a warning when no synonym definitions are found for a list entity', function(done){
|
||||||
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/missing-synonyms.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis --in ${TEST_ROOT}/testcases/missing-synonyms.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.ok(stdout.includes('[WARN] No synonyms list found'));
|
assert.ok(stdout.includes('[WARN] No synonyms list found'));
|
||||||
done();
|
done();
|
||||||
|
@ -323,9 +317,8 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Successfully spits out qnamaker alterations list when specified in .lu files', function(done){
|
it('Successfully spits out qnamaker alterations list when specified in .lu files', function(done){
|
||||||
exec(`node ${ludown} parse toqna -a --in ${TEST_ROOT}/../examples/qna-alterations.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna -a --in ${TEST_ROOT}/../examples/qna-alterations.lu -o ${TEST_ROOT}/output --verbose`, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
assert.ok(stdout.includes('Successfully wrote QnA Alterations JSON file'));
|
assert.ok(stdout.includes('Successfully wrote QnA Alterations JSON file'));
|
||||||
done();
|
done();
|
||||||
|
@ -347,7 +340,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Collate can correctly merge LUIS content split across LU files', function(done){
|
it('Collate can correctly merge LUIS content split across LU files', function(done){
|
||||||
exec(`node ${ludown} parse toluis -l ${TEST_ROOT}/testcases/collate -n collated-luis -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis -l ${TEST_ROOT}/testcases/collate -n collated-luis -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/collated-luis.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collated-luis.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/collated-luis.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collated-luis.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -356,9 +349,9 @@ describe('The example lu files', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Collate can correctly merge LUIS content split across LU files to generate batch test input', function(done){
|
it('Collate can correctly merge LUIS content split across LU files to generate batch test input', function(done){
|
||||||
exec(`node ${ludown} parse toluis -l ${TEST_ROOT}/testcases/collate -n collated-luis -o ${TEST_ROOT}/output -t`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toluis -l ${TEST_ROOT}/testcases/collate -n collated-luis -o ${TEST_ROOT}/output -t`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/collated-luis_LUISBatchTest.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collated-luis_LUISBatchTest.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/collated-luis_LUISBatchTest.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collated-luis_LUISBatchTest.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -367,9 +360,9 @@ describe('The example lu files', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Collate can correctly merge QnA content split across LU files', function(done){
|
it('Collate can correctly merge QnA content split across LU files', function(done){
|
||||||
exec(`node ${ludown} parse toqna -l ${TEST_ROOT}/testcases/collate -n collate-qna -o ${TEST_ROOT}/output`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna -l ${TEST_ROOT}/testcases/collate -n collate-qna -o ${TEST_ROOT}/output`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/collate-qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/collate-qna.json'))));
|
assert.deepEqual(JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/output/collate-qna.json'))), JSON.parse(sanitizeExampleJson(txtfile.readSync(TEST_ROOT + '/verified/collate-qna.json'))));
|
||||||
done();
|
done();
|
||||||
|
@ -380,7 +373,7 @@ describe('The example lu files', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Collate can correctly merge QnA word alteration content split across LU files', function(done){
|
it('Collate can correctly merge QnA word alteration content split across LU files', function(done){
|
||||||
exec(`node ${ludown} parse toqna -l ${TEST_ROOT}/testcases/collate -n alterations -o ${TEST_ROOT}/output -a`, (error, stdout, stderr) => {
|
exec(`node ${ludown} parse toqna -l ${TEST_ROOT}/testcases/collate -n alterations -o ${TEST_ROOT}/output -a`, () => {
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/alterations_Alterations.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collate_Alterations.json')));
|
assert.deepEqual(JSON.parse(txtfile.readSync(TEST_ROOT + '/output/alterations_Alterations.json')), JSON.parse(txtfile.readSync(TEST_ROOT + '/verified/collate_Alterations.json')));
|
||||||
done();
|
done();
|
||||||
|
@ -389,13 +382,12 @@ describe('The example lu files', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Refresh command can successfully generate content from LUIS, QnA and QnA Alterations', function(done){
|
it('Refresh command can successfully generate content from LUIS, QnA and QnA Alterations', function (done) {
|
||||||
exec(`node ${ludown} refresh -i ${TEST_ROOT}/verified/collated-luis.json -q ${TEST_ROOT}/verified/collate-qna.json -a ${TEST_ROOT}/verified/collate_Alterations.json -n collate_refresh -o ${TEST_ROOT}/output --skip_header`, (error, stdout, stderr) => {
|
exec(`node ${ludown} refresh -i ${TEST_ROOT}/verified/collated-luis.json -q ${TEST_ROOT}/verified/collate-qna.json -a ${TEST_ROOT}/verified/collate_Alterations.json -n collate_refresh -o ${TEST_ROOT}/output --skip_header`, () => {
|
||||||
try {
|
try {
|
||||||
compareFiles(TEST_ROOT + '/verified/collate_refresh.lu', TEST_ROOT + '/output/collate_refresh.lu');
|
compareFiles(TEST_ROOT + '/verified/collate_refresh.lu', TEST_ROOT + '/output/collate_refresh.lu');
|
||||||
done();
|
done();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe('With helper functions', function() {
|
||||||
it('splitFileBySections throws when no intent definition found in a line', function(done){
|
it('splitFileBySections throws when no intent definition found in a line', function(done){
|
||||||
let testLu = `#Greeting`;
|
let testLu = `#Greeting`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -39,7 +39,7 @@ describe('With helper functions', function() {
|
||||||
let testLu = `$test:123=
|
let testLu = `$test:123=
|
||||||
# Greeting`;
|
# Greeting`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done();
|
done();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done(err);
|
done(err);
|
||||||
|
@ -50,7 +50,7 @@ describe('With helper functions', function() {
|
||||||
let testLu = `# Greeting
|
let testLu = `# Greeting
|
||||||
# None`;
|
# None`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done();
|
done();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done(err);
|
done(err);
|
||||||
|
@ -61,7 +61,7 @@ describe('With helper functions', function() {
|
||||||
let testLu = `# ? 123
|
let testLu = `# ? 123
|
||||||
# Greeting`;
|
# Greeting`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -72,7 +72,7 @@ describe('With helper functions', function() {
|
||||||
let testLu = `# ? 123
|
let testLu = `# ? 123
|
||||||
[test](1.lu)`;
|
[test](1.lu)`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -82,7 +82,7 @@ describe('With helper functions', function() {
|
||||||
it('splitFileBySections throws when no answer found for question', function(done){
|
it('splitFileBySections throws when no answer found for question', function(done){
|
||||||
let testLu = `# ? 123`;
|
let testLu = `# ? 123`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -95,7 +95,7 @@ describe('With helper functions', function() {
|
||||||
$commPreference:call
|
$commPreference:call
|
||||||
- phone call`;
|
- phone call`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -108,7 +108,7 @@ describe('With helper functions', function() {
|
||||||
$commPreference:call
|
$commPreference:call
|
||||||
- phone call`;
|
- phone call`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -118,7 +118,7 @@ describe('With helper functions', function() {
|
||||||
it('splitFileBySections throws when invalid entity definition is found', function(done){
|
it('splitFileBySections throws when invalid entity definition is found', function(done){
|
||||||
let testLu = `$PREBUILT:datetimeV23`;
|
let testLu = `$PREBUILT:datetimeV23`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -128,7 +128,7 @@ describe('With helper functions', function() {
|
||||||
it('splitFileBySections throws when invalid entity definition is found', function(done){
|
it('splitFileBySections throws when invalid entity definition is found', function(done){
|
||||||
let testLu = `$PREBUILT=datetimeV23`;
|
let testLu = `$PREBUILT=datetimeV23`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
@ -139,7 +139,7 @@ describe('With helper functions', function() {
|
||||||
let testLu = `$commPreference:cal=l
|
let testLu = `$commPreference:cal=l
|
||||||
- phone call`;
|
- phone call`;
|
||||||
try {
|
try {
|
||||||
let test = helpers.splitFileBySections(testLu, false);
|
helpers.splitFileBySections(testLu, false);
|
||||||
done('Test failed: splitFileBySections did not throw!');
|
done('Test failed: splitFileBySections did not throw!');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License.
|
* Licensed under the MIT License.
|
||||||
*/
|
*/
|
||||||
const chai = require('chai');
|
|
||||||
const assert = chai.assert;
|
|
||||||
const parseFile = require('../lib/parseFileContents');
|
const parseFile = require('../lib/parseFileContents');
|
||||||
|
|
||||||
describe('With helper functions', function() {
|
describe('With helper functions', function() {
|
||||||
|
@ -19,17 +17,17 @@ $commPreference:phraseList
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(function(parsedContent) {
|
.then(function(parsedContent) {
|
||||||
parseFile.validateLUISBlob(parsedContent.LUISJsonStructure)
|
parseFile.validateLUISBlob(parsedContent.LUISJsonStructure)
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
})
|
})
|
||||||
.catch(err => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.catch(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws on invalid file refs', function(done) {
|
it('parseFile throws on invalid file refs', function(done) {
|
||||||
let luFile = `[test]()`;
|
let luFile = `[test]()`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws on nested entity refs', function(done) {
|
it('parseFile throws on nested entity refs', function(done) {
|
||||||
|
@ -37,8 +35,8 @@ $commPreference:phraseList
|
||||||
- hi {userName=foo {lastName=bar}}
|
- hi {userName=foo {lastName=bar}}
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws if a QnA maker question does not have a list decoration', function(done) {
|
it('parseFile throws if a QnA maker question does not have a list decoration', function(done) {
|
||||||
|
@ -46,8 +44,8 @@ $commPreference:phraseList
|
||||||
question 2
|
question 2
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws if a QnA maker filter section does not have list decoration', function(done) {
|
it('parseFile throws if a QnA maker filter section does not have list decoration', function(done) {
|
||||||
|
@ -56,8 +54,8 @@ question 2
|
||||||
location = seattle
|
location = seattle
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws if a QnA maker filter section does not have valid key = value pair', function(done) {
|
it('parseFile throws if a QnA maker filter section does not have valid key = value pair', function(done) {
|
||||||
|
@ -66,8 +64,8 @@ location = seattle
|
||||||
- location
|
- location
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile parses multi-line answer correctly', function(done) {
|
it('parseFile parses multi-line answer correctly', function(done) {
|
||||||
|
@ -78,8 +76,8 @@ test
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done())
|
.then(() => done())
|
||||||
.catch(err => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.catch(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws on conflicting phraseList definitions', function(done) {
|
it('parseFile throws on conflicting phraseList definitions', function(done) {
|
||||||
|
@ -91,8 +89,8 @@ test
|
||||||
|
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws if phraseList value does not have list decoration', function(done) {
|
it('parseFile throws if phraseList value does not have list decoration', function(done) {
|
||||||
|
@ -100,8 +98,8 @@ test
|
||||||
m&m,mars,mints,spearmings,payday,jelly,kit kat,kitkat,twix
|
m&m,mars,mints,spearmings,payday,jelly,kit kat,kitkat,twix
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parseFile throws if List synonyms do not have list decoration', function(done) {
|
it('parseFile throws if List synonyms do not have list decoration', function(done) {
|
||||||
|
@ -109,8 +107,7 @@ m&m,mars,mints,spearmings,payday,jelly,kit kat,kitkat,twix
|
||||||
m&m,mars,mints,spearmings,payday,jelly,kit kat,kitkat,twix
|
m&m,mars,mints,spearmings,payday,jelly,kit kat,kitkat,twix
|
||||||
`;
|
`;
|
||||||
parseFile.parseFile(luFile, false, 'en-us')
|
parseFile.parseFile(luFile, false, 'en-us')
|
||||||
.then(res => done('Test fail. validateLUISBlob did not throw when expected!'))
|
.then(() => done('Test fail. validateLUISBlob did not throw when expected!'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -17,7 +17,7 @@ describe('With the parseAndTranslate method', function() {
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(`> This is a comment
|
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(`> This is a comment
|
||||||
`));
|
`));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
@ -29,8 +29,8 @@ done();
|
||||||
}
|
}
|
||||||
translate.parseAndTranslate(testData.tests.qna.luFile, TRANSLATE_KEY, testData.tests.qna.langCode, '', false, false, false)
|
translate.parseAndTranslate(testData.tests.qna.luFile, TRANSLATE_KEY, testData.tests.qna.langCode, '', false, false, false)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.qna.translatedContent));
|
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.qna.translatedContent));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
@ -43,7 +43,7 @@ done();
|
||||||
translate.parseAndTranslate(testData.tests.phraseList.luFile, TRANSLATE_KEY, testData.tests.phraseList.langCode, '', false, false, false)
|
translate.parseAndTranslate(testData.tests.phraseList.luFile, TRANSLATE_KEY, testData.tests.phraseList.langCode, '', false, false, false)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.phraseList.translatedContent));
|
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.phraseList.translatedContent));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
@ -55,8 +55,8 @@ done();
|
||||||
translate.parseAndTranslate(testData.tests.badLu.luFile, TRANSLATE_KEY, testData.tests.badLu.langCode, '', false, false, false)
|
translate.parseAndTranslate(testData.tests.badLu.luFile, TRANSLATE_KEY, testData.tests.badLu.langCode, '', false, false, false)
|
||||||
.then(res => done(res))
|
.then(res => done(res))
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
assert.equal(err.errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(err.errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ done();
|
||||||
translate.parseAndTranslate(testData.tests.fileRef.luFile, TRANSLATE_KEY, testData.tests.fileRef.langCode, '', false, false, false)
|
translate.parseAndTranslate(testData.tests.fileRef.luFile, TRANSLATE_KEY, testData.tests.fileRef.langCode, '', false, false, false)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.fileRef.luFile + NEWLINE));
|
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.fileRef.luFile + NEWLINE));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
@ -88,10 +88,10 @@ done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Invalid key with comments throws', function(done) {
|
it('Invalid key with comments throws', function(done) {
|
||||||
if (!TRANSLATE_KEY) {
|
if (!TRANSLATE_KEY) {
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
translate.parseAndTranslate(`> test comment
|
translate.parseAndTranslate(`> test comment
|
||||||
`, TRANSLATE_KEY + '2', testData.tests.badLu.langCode, '', true, false, false)
|
`, TRANSLATE_KEY + '2', testData.tests.badLu.langCode, '', true, false, false)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
|
@ -119,16 +119,16 @@ done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Labelled entity values are translated correctly', function(done) {
|
it('Labelled entity values are translated correctly', function (done) {
|
||||||
if (!TRANSLATE_KEY) {
|
if (!TRANSLATE_KEY) {
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
translate.parseAndTranslate(testData.tests.labelledEntityValue.luFile, TRANSLATE_KEY, testData.tests.labelledEntityValue.langCode, '', false, true, false)
|
translate.parseAndTranslate(testData.tests.labelledEntityValue.luFile, TRANSLATE_KEY, testData.tests.labelledEntityValue.langCode, '', false, true, false)
|
||||||
.then(function(res) {
|
.then(function (res) {
|
||||||
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.labelledEntityValue.translatedContent));
|
assert.equal(helpers.sanitizeNewLines(res), helpers.sanitizeNewLines(testData.tests.labelledEntityValue.translatedContent));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Invalid key with QnA throws', function(done) {
|
it('Invalid key with QnA throws', function(done) {
|
||||||
|
@ -153,10 +153,10 @@ done();
|
||||||
}
|
}
|
||||||
translate.parseAndTranslate(`# Greeting
|
translate.parseAndTranslate(`# Greeting
|
||||||
`, TRANSLATE_KEY, testData.tests.badLu.langCode, '', false, false, true)
|
`, TRANSLATE_KEY, testData.tests.badLu.langCode, '', false, false, true)
|
||||||
.then(function(res) {
|
.then(function() {
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function() {
|
||||||
done('Test Fail! Threw when not expected');
|
done('Test Fail! Threw when not expected');
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -195,8 +195,8 @@ done();
|
||||||
}
|
}
|
||||||
translate.parseAndTranslate(testData.tests.intentsAndUtterances.luFile, TRANSLATE_KEY, testData.tests.intentsAndUtterances.langCode, 'en-us', true, false, true)
|
translate.parseAndTranslate(testData.tests.intentsAndUtterances.luFile, TRANSLATE_KEY, testData.tests.intentsAndUtterances.langCode, 'en-us', true, false, true)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal(res, helpers.sanitizeNewLines(testData.tests.intentsAndUtterances.translatedContent));
|
assert.equal(res, helpers.sanitizeNewLines(testData.tests.intentsAndUtterances.translatedContent));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
@ -208,8 +208,8 @@ done();
|
||||||
translate.parseAndTranslate(`# ? hello
|
translate.parseAndTranslate(`# ? hello
|
||||||
\`\`\`markdown`, TRANSLATE_KEY, 'de', 'en-us', true, false, true)
|
\`\`\`markdown`, TRANSLATE_KEY, 'de', 'en-us', true, false, true)
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
assert.equal('# ? Hallo' + NEWLINE + '```markdown' + NEWLINE, res);
|
assert.equal('# ? Hallo' + NEWLINE + '```markdown' + NEWLINE, res);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err))
|
.catch(err => done(err))
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file does not parse as luis content', function(done) {
|
it('throws when input file does not parse as luis content', function(done) {
|
||||||
let invalidFile = resolvePath('test/1.lu')
|
let invalidFile = resolvePath('test/1.lu')
|
||||||
toLU.generateMarkdown({LUIS_File:invalidFile})
|
toLU.generateMarkdown({LUIS_File:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.FILE_OPEN_ERROR);
|
assert.equal(new exception(err).errCode, retCode.errorCode.FILE_OPEN_ERROR);
|
||||||
done();
|
done();
|
||||||
|
@ -30,7 +30,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file has composite entities', function(done) {
|
it('throws when input file has composite entities', function(done) {
|
||||||
let invalidFile = resolvePath('test/testcases/InvalidLUISModel.json')
|
let invalidFile = resolvePath('test/testcases/InvalidLUISModel.json')
|
||||||
toLU.generateMarkdown({LUIS_File:invalidFile})
|
toLU.generateMarkdown({LUIS_File:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
|
@ -40,7 +40,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file has regex entities', function(done) {
|
it('throws when input file has regex entities', function(done) {
|
||||||
let invalidFile = resolvePath('test/testcases/InvalidLUISModel1.json')
|
let invalidFile = resolvePath('test/testcases/InvalidLUISModel1.json')
|
||||||
toLU.generateMarkdown({LUIS_File:invalidFile})
|
toLU.generateMarkdown({LUIS_File:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
|
@ -50,7 +50,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file has regex features', function(done) {
|
it('throws when input file has regex features', function(done) {
|
||||||
let invalidFile = resolvePath('test/testcases/InvalidLUISModel2.json')
|
let invalidFile = resolvePath('test/testcases/InvalidLUISModel2.json')
|
||||||
toLU.generateMarkdown({LUIS_File:invalidFile})
|
toLU.generateMarkdown({LUIS_File:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
|
@ -60,7 +60,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file does not parse as qna content', function(done) {
|
it('throws when input file does not parse as qna content', function(done) {
|
||||||
let invalidFile = resolvePath('test/1.lu')
|
let invalidFile = resolvePath('test/1.lu')
|
||||||
toLU.generateMarkdown({QNA_FILE:invalidFile})
|
toLU.generateMarkdown({QNA_FILE:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.FILE_OPEN_ERROR);
|
assert.equal(new exception(err).errCode, retCode.errorCode.FILE_OPEN_ERROR);
|
||||||
done();
|
done();
|
||||||
|
@ -70,7 +70,7 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file does not parse as qna content', function(done) {
|
it('throws when input file does not parse as qna content', function(done) {
|
||||||
let invalidFile = resolvePath('examples/1.lu')
|
let invalidFile = resolvePath('examples/1.lu')
|
||||||
toLU.generateMarkdown({LUIS_File:invalidFile})
|
toLU.generateMarkdown({LUIS_File:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
|
@ -80,11 +80,10 @@ describe('With toLU module', function() {
|
||||||
it('throws when input file does not parse as LUIS content', function(done) {
|
it('throws when input file does not parse as LUIS content', function(done) {
|
||||||
let invalidFile = resolvePath('examples/1.lu')
|
let invalidFile = resolvePath('examples/1.lu')
|
||||||
toLU.generateMarkdown({QNA_FILE:invalidFile})
|
toLU.generateMarkdown({QNA_FILE:invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
assert.equal(new exception(err).errCode, retCode.errorCode.INVALID_INPUT_FILE);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License.
|
* Licensed under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
/*eslint no-console: ["error", { allow: ["log"] }] */
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const assert = chai.assert;
|
const assert = chai.assert;
|
||||||
const translate = require('../lib/translate');
|
const translate = require('../lib/translate');
|
||||||
|
@ -37,13 +38,13 @@ describe('With translate module', function() {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Unable to create test/output folder. The tests will fail');
|
console.log('Unable to create test/output folder. The tests will fail');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when invalid file is specified', function(done){
|
it('should throw when invalid file is specified', function(done){
|
||||||
let invalidFile = resolvePath('test/1.lu');
|
let invalidFile = resolvePath('test/1.lu');
|
||||||
translate.translateContent({in: invalidFile})
|
translate.translateContent({in: invalidFile})
|
||||||
.then(res => done('Test fail! Did not throw when expected'))
|
.then(() => done('Test fail! Did not throw when expected'))
|
||||||
.catch(err => done())
|
.catch(() => done())
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly localize the file content', function(done) {
|
it('correctly localize the file content', function(done) {
|
||||||
|
@ -51,7 +52,7 @@ describe('With translate module', function() {
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
let luFilePath = resolvePath('examples/1.lu');
|
let luFilePath = resolvePath('examples/1.lu');
|
||||||
exec(`node ${ludown} translate -k ${TRANSLATE_KEY} -t de -o ${LUDOWN_ROOT}/test/output -n 1_de --verbose --in ` + luFilePath, (error, stdout, stderr) => {
|
exec(`node ${ludown} translate -k ${TRANSLATE_KEY} -t de -o ${LUDOWN_ROOT}/test/output -n 1_de --verbose --in ` + luFilePath, (error, stdout) => {
|
||||||
try {
|
try {
|
||||||
compareFiles(LUDOWN_ROOT + '/test/output/de/1.lu', LUDOWN_ROOT + '/test/verified/1.lu');
|
compareFiles(LUDOWN_ROOT + '/test/output/de/1.lu', LUDOWN_ROOT + '/test/verified/1.lu');
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
|
@ -69,7 +70,7 @@ describe('With translate module', function() {
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
done(res);
|
done(res);
|
||||||
})
|
})
|
||||||
.catch(function(err){
|
.catch(function(){
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -114,10 +115,10 @@ describe('With translate module', function() {
|
||||||
}
|
}
|
||||||
let fileContent = `- 123`;
|
let fileContent = `- 123`;
|
||||||
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'dex', '', false, true, SHOW_LOGS)
|
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'dex', '', false, true, SHOW_LOGS)
|
||||||
.then(function(res) {
|
.then(function() {
|
||||||
done('Test fail! Did not throw when expected');
|
done('Test fail! Did not throw when expected');
|
||||||
})
|
})
|
||||||
.catch (err => done());
|
.catch (() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Translate throw with invalid src lang code', function(done) {
|
it('Translate throw with invalid src lang code', function(done) {
|
||||||
|
@ -126,10 +127,10 @@ describe('With translate module', function() {
|
||||||
}
|
}
|
||||||
let fileContent = `[123]('./1.lu')`;
|
let fileContent = `[123]('./1.lu')`;
|
||||||
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'de', 'esx', false, true, SHOW_LOGS)
|
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'de', 'esx', false, true, SHOW_LOGS)
|
||||||
.then(function(res) {
|
.then(function() {
|
||||||
done('Test fail! Did not throw when expected');
|
done('Test fail! Did not throw when expected');
|
||||||
})
|
})
|
||||||
.catch (err => done());
|
.catch (() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Link text can be left untranslated', function(done) {
|
it('Link text can be left untranslated', function(done) {
|
||||||
|
@ -156,10 +157,10 @@ describe('With translate module', function() {
|
||||||
let fileContent = `\`\`\`markdown
|
let fileContent = `\`\`\`markdown
|
||||||
test 123`;
|
test 123`;
|
||||||
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'de', 'esx', false, true, SHOW_LOGS)
|
trHelpers.parseAndTranslate(fileContent, TRANSLATE_KEY, 'de', 'esx', false, true, SHOW_LOGS)
|
||||||
.then(function(res) {
|
.then(function() {
|
||||||
done('Test fail! Did not throw when expected');
|
done('Test fail! Did not throw when expected');
|
||||||
})
|
})
|
||||||
.catch (err => done());
|
.catch (() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Alterations are translated correctly', function(done) {
|
it('Alterations are translated correctly', function(done) {
|
||||||
|
@ -178,5 +179,4 @@ describe('With translate module', function() {
|
||||||
})
|
})
|
||||||
.catch (err => done(err));
|
.catch (err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -18,7 +18,9 @@
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"env": {
|
"env": {
|
||||||
"node": true
|
"node": true,
|
||||||
|
"es6": true,
|
||||||
|
"mocha": true
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче