it('failure to find ref throws', function(done) { let luContent = ` # foo - [tom](tom#*)`; luMerger.Build([new luObj(luContent)], false, undefined, findLuFiles) .then(res => done(res)) .catch(err => { assert.isTrue(err.text.includes('Cannot find reference')) done() }) })
it('Nested entity references convert correctly back to LU', async () => { let luisApp = luisBuilder.fromJson(bf627); let luisAppInLu = luisApp.parseToLuContent() assert.isTrue(luisAppInLu.includes(`- when I use the {@outer=same {@inner=text} twice in nested ML entity text}`)) })
assert.isTrue(qnaResult.get(path.join(rootDir, "dia1.en-us.qna")).Sections.filter(s => s.SectionType === sectionTypes.QNASECTION)[1].Body.includes(`# ? common_question${NEWLINE}${NEWLINE}**Filters:**${NEWLINE}- dialogName=dia1${NEWLINE}${NEWLINE}\`\`\`${NEWLINE}this is common answer${NEWLINE}\`\`\`${NEWLINE}${NEWLINE}`))
describe('multi-content', function(){ it('BF-CLI #652 - multi entity definition across docs is merged correctly', function(done){ let luContent1 = new luObj(`@ list blah= - something: @ composite foo = [blah] `); let luContent2 = new luObj(`# utterances - @{foo= something}`); luBuilder.fromLUAsync([luContent1, luContent2]) .then(res => { assert.isTrue(res.entities.length === 0); assert.equal(res.composites[0].name, "foo"); done() }) .catch(err => done(err)) }) })
it('update section test', () => { let newFileConent = `# CheckEmail - check my email - show my emails - check my mail box please > this is comment when updating simpleIntentSection`; let sectionId = luresource.Sections[1].Id; luresource = new SectionOperator(luresource).updateSection(luresource.Sections[1].Id, newFileConent); assert.equal(luresource.Errors.length, 0); assert.equal(luresource.Sections.length, 2); assert.equal(luresource.Sections[1].Errors.length, 0); assert.equal(luresource.Sections[1].SectionType, LUSectionTypes.SIMPLEINTENTSECTION); assert.equal(luresource.Sections[1].Name, 'CheckEmail'); assert.equal(luresource.Sections[1].Id, sectionId); assert.equal(luresource.Sections[1].UtteranceAndEntitiesMap.length, 3); assert.equal(luresource.Sections[1].UtteranceAndEntitiesMap[0].utterance, 'check my email'); assert.equal(luresource.Sections[1].UtteranceAndEntitiesMap[1].utterance, 'show my emails'); assert.equal(luresource.Sections[1].UtteranceAndEntitiesMap[2].utterance, 'check my mail box please'); assert.isTrue(luresource.Sections[1].Body.includes('> this is comment when updating simpleIntentSection')); assert.isFalse(luresource.Sections[1].Body.includes('> this is comment when adding simpleIntentSection')); });
// FIXME skipping as this is behaving erratically (and it's not a fundamental function) describe('Categories method', () => { it('should fetch valid list of categories', () => { return gplay.categories().then(categories => { assert.isArray(categories); assert.isTrue(categories.length > 0); }); }); it('should have all categories from constant list of categories', () => { return gplay.categories().then(categories => { const categoriesConst = Object.keys(gplay.category); assert.deepEqual( R.difference(categories, categoriesConst), [], 'Google Play has categories that are not in "category" constant' ); assert.deepEqual( R.difference(categoriesConst, categories), [], 'There is some categories in the constant that were removed from Play Store' ); }); }); });
assert.isTrue(result.qnaContents[0].content.includes( `!# @qna.pair.source = custom editorial${NEWLINE}${NEWLINE}## ? help${NEWLINE}- could you help${NEWLINE}${NEWLINE}\`\`\`markdown${NEWLINE}help answer${NEWLINE}\`\`\`${NEWLINE}${NEWLINE}> !# @qna.pair.source = custom editorial${NEWLINE}${NEWLINE}## ? welcome${NEWLINE}${NEWLINE}\`\`\`markdown${NEWLINE}welcome here${NEWLINE}\`\`\`${NEWLINE}${NEWLINE}> !# @qna.pair.source = custom editorial${NEWLINE}${NEWLINE}## ? cancel${NEWLINE}${NEWLINE}\`\`\`markdown${NEWLINE}cancel the task${NEWLINE}\`\`\`${NEWLINE}${NEWLINE}> !# @qna.pair.source = custom editorial${NEWLINE}${NEWLINE}## ? stop${NEWLINE}${NEWLINE}\`\`\`markdown${NEWLINE}stop that${NEWLINE}\`\`\``)) })
it('Circular references throws', function(done) { let luContent = ` # intent1 - [refl1](refl1#*)` luMerger.Build([new luObj(luContent, new luOptions('tloop', true))], false, undefined, findLuFiles) .then(res => done(res)) .catch(err => { assert.isTrue(err.text.includes('Loop detected')) done() }) })
assert.isTrue(foundIndex > -1) assert.equal(luResult.get('./dia2/dia2.lu').Sections[foundIndex].Body, `- book a flight for me`) })
describe('phrase lists with enabledForAllModels', function(){ it('BF-CLI #789 - phrase lists with enabledForAllModels parse correctly', function(done){ let luContent1 = new luObj(`@ phraselist Iam_gpl(interchangeable) enabledForAllModels = - I - I'm - I am - I be @ phraselist my_gpl(interchangeable) enabledForAllModels = - my - mine - me `); luBuilder.fromLUAsync([luContent1]) .then(res => { assert.isTrue(res.model_features.length === 2); done() }) .catch(err => done(err)) }) })
assert.isTrue(result.luContents[0].content.includes( `help${NEWLINE}- could you help${NEWLINE}- can you help me${NEWLINE}${NEWLINE}${NEWLINE}## cancel${NEWLINE}- cancel that${NEWLINE}- cancel the task${NEWLINE}- stop that${NEWLINE}${NEWLINE}${NEWLINE}## welcome${NEWLINE}- welcome here` ))
assert.isTrue(luResult.get(path.join(rootDir, "dia1.en-us.lu")).Sections.filter(s => s.SectionType === sectionTypes.SIMPLEINTENTSECTION)[0].Body.includes(`- hotel in Seattle${NEWLINE}- this is common utterance`))
assert.isTrue(qnaResult.get(path.join(rootDir, "main.en-us.qna")).Sections.filter(s => s.SectionType === sectionTypes.QNASECTION)[1].Body.includes(`# ? common_question${NEWLINE}${NEWLINE}**Filters:**${NEWLINE}- dialogName=main${NEWLINE}${NEWLINE}\`\`\`${NEWLINE}this is common answer${NEWLINE}\`\`\`${NEWLINE}${NEWLINE}`))
assert.isTrue(luResult.get(path.join(rootDir, "main.en-us.lu")).Sections.filter(s => s.SectionType === sectionTypes.SIMPLEINTENTSECTION)[1].Body.includes(`- this is common utterance`))