/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 */ import { TreeUtils } from './TreeUtils' ; describe ( 'TreeUtils' , ( ) => { describe ( 'isInTree' , ( ) => { const trainDialog1 = { "tags" : [ ] , "description" : "" , "trainDialogId" : "667421c2-54be-4187-836d-9e31827a0096" , "rounds" : [ { "extractorStep" : { "textVariations" : [ { "text" : "add a keyboard language in windows 10" , "labelEntities" : [ ] } , { "text" : "add an input language to windows 10" , "labelEntities" : [ ] } , { "text" : "switch keyboard languages in windows 10" , "labelEntities" : [ ] } , { "text" : "windows 10 change keyboard languages" , "labelEntities" : [ ] } , { "text" : "change language in windows 10" , "labelEntities" : [ ] } , { "text" : "how to change language in windows 10" , "labelEntities" : [ ] } , { "text" : "add display language windows 10" , "labelEntities" : [ ] } , { "text" : "keyboard layout" , "labelEntities" : [ ] } , { "text" : "switch keyboard layout" , "labelEntities" : [ ] } , { "text" : "change keyboard layout" , "labelEntities" : [ ] } , { "text" : "changing keyboard layout" , "labelEntities" : [ ] } , { "text" : "add input language windows 10" , "labelEntities" : [ ] } , { "text" : "how to add a language pack to windows 10" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Install a new language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "43e4afcc-542b-4349-940b-8d3947acdeb0" , } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Change my keyboard language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "No, I need to add a new keyboard language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } ] } ] , "clientData" : { "importHashes" : [ ] } , "initialFilledEntities" : [ ] , "createdDateTime" : "2019-10-11T23:24:23.718253+00:00" , "lastModifiedDateTime" : "2019-10-11T23:24:23+00:00" } as any ; const trainDialog2 = { "tags" : [ ] , "description" : "" , "trainDialogId" : "a0d1cb85-9dd8-49d6-9d72-86a3894d7796" , "rounds" : [ { "extractorStep" : { "textVariations" : [ { "text" : "add a keyboard language in windows 10" , "labelEntities" : [ ] } , { "text" : "add an input language to windows 10" , "labelEntities" : [ ] } , { "text" : "switch keyboard languages in windows 10" , "labelEntities" : [ ] } , { "text" : "windows 10 change keyboard languages" , "labelEntities" : [ ] } , { "text" : "change language in windows 10" , "labelEntities" : [ ] } , { "text" : "how to change language in windows 10" , "labelEntities" : [ ] } , { "text" : "add display language windows 10" , "labelEntities" : [ ] } , { "text" : "keyboard layout" , "labelEntities" : [ ] } , { "text" : "switch keyboard layout" , "labelEntities" : [ ] } , { "text" : "change keyboard layout" , "labelEntities" : [ ] } , { "text" : "changing keyboard layout" , "labelEntities" : [ ] } , { "text" : "add input language windows 10" , "labelEntities" : [ ] } , { "text" : "how to add a language pack to windows 10" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Install a new language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Change my keyboard language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Yes, Iʼm done" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } ] } ] , "clientData" : { "importHashes" : [ ] } , "initialFilledEntities" : [ ] , "createdDateTime" : "2019-10-11T23:24:24.7875681+00:00" , "lastModifiedDateTime" : "2019-10-11T23:24:24+00:00" } as any ; const trainDialog3 = { "tags" : [ ] , "description" : "" , "trainDialogId" : "1a9e9b7c-9545-48ac-926c-d6cd48f72623" , "rounds" : [ { "extractorStep" : { "textVariations" : [ { "text" : "add a keyboard language in windows 10" , "labelEntities" : [ ] } , { "text" : "add an input language to windows 10" , "labelEntities" : [ ] } , { "text" : "switch keyboard languages in windows 10" , "labelEntities" : [ ] } , { "text" : "windows 10 change keyboard languages" , "labelEntities" : [ ] } , { "text" : "change language in windows 10" , "labelEntities" : [ ] } , { "text" : "how to change language in windows 10" , "labelEntities" : [ ] } , { "text" : "add display language windows 10" , "labelEntities" : [ ] } , { "text" : "keyboard layout" , "labelEntities" : [ ] } , { "text" : "switch keyboard layout" , "labelEntities" : [ ] } , { "text" : "change keyboard layout" , "labelEntities" : [ ] } , { "text" : "changing keyboard layout" , "labelEntities" : [ ] } , { "text" : "add input language windows 10" , "labelEntities" : [ ] } , { "text" : "how to add a language pack to windows 10" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Install a new language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Change my display language" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "5525778e-5e16-42a7-9053-3c1d930fa217" } ] } , { "extractorStep" : { "textVariations" : [ { "text" : "Yes" , "labelEntities" : [ ] } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } ] } ] , "clientData" : { "importHashes" : [ ] } , "initialFilledEntities" : [ ] , "createdDateTime" : "2019-10-11T23:24:25.9546743+00:00" , "lastModifiedDateTime" : "2019-10-11T23:24:26+00:00" } as any ; const trainDialog4 = { "trainDialogId" : "" , "sourceLogDialogId" : "7afe54e4-b110-4559-aa02-1358d417413f" , "rounds" : [ { "extractorStep" : { "textVariations" : [ { "labelEntities" : [ ] , "text" : "remove language" } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "43e4afcc-542b-4349-940b-8d3947acdeb0" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9328774213790894 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.021006131544709206 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } , { "score" : 0.012838832102715969 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.009779268875718117 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.006072659511119127 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.005234585143625736 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.0034483515191823244 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.0033303953241556883 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0020454670302569866 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.001664016512222588 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.0012577311135828495 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.00044515912304632366 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } ] , "unscoredActions" : [ ] } } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9875692129135132 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.0036190657410770655 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.002345742890611291 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.0018373478669673204 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.0012114358833059669 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.0010657196398824453 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "score" : 0.0007987662102095783 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } , { "score" : 0.0004141951212659478 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.00040979025652632117 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0003796368546318263 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.00027159173623658717 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.00007751074736006558 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } ] , "unscoredActions" : [ ] } } ] } , { "extractorStep" : { "textVariations" : [ { "labelEntities" : [ ] , "text" : "change my display language" } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9922149181365967 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.0031481622718274593 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "score" : 0.0028868585359305143 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.0005186109920032322 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0004335134581197053 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.00024853734066709876 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.00018752855248749256 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.00014449779700953513 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.00010129488509846851 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.00006576534360647202 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.000026819259801413864 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.00002356073855480645 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } ] , "unscoredActions" : [ ] } } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "5525778e-5e16-42a7-9053-3c1d930fa217" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9978663325309753 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.0007321720477193594 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.00039192455005832016 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.00032639893470332026 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.00021645658125635237 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.00018811329209711403 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.00018709598225541413 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.00003991329504060559 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0000182971270987764 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "score" : 0.0000158043549163267 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.000014394680874829646 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.00000312699035021069 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } ] , "unscoredActions" : [ ] } } ] } , { "extractorStep" : { "textVariations" : [ { "labelEntities" : [ ] , "text" : "no" } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "caac01e9-de0f-425f-b8c9-0c12a0836118" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9941326379776001 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.0026351010892540216 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.001060638576745987 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0009162776987068355 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.0006678157951682806 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.00024008078617043793 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.00017712444241624326 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.00005654783672071062 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.00005400867303251289 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.0000340423830493819 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.000013838467566529289 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } , { "score" : 0.00001188338046631543 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } ] , "unscoredActions" : [ ] } } , { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.9970620274543762 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.0012060474837198853 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.0004954428295604885 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.0003650840080808848 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.0003218165074940771 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.0002932618954218924 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.00008540530689060688 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.00006844189920229837 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.0000626845212536864 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.00002413020956737455 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.000008265432370535564 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "score" : 0.000007415256732201669 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } ] , "unscoredActions" : [ ] } } ] } , { "extractorStep" : { "textVariations" : [ { "labelEntities" : [ ] , "text" : "i'm getting an error message" } ] } , "scorerSteps" : [ { "input" : { "filledEntities" : [ ] , "context" : { } , "maskedActions" : [ ] } , "labelAction" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" , "uiScoreResponse" : { "scoredActions" : [ { "score" : 0.983279287815094 , "actionId" : "d20fed53-2fff-460d-ae8b-f8b8fd156e78" } , { "score" : 0.0046980120241642 , "actionId" : "a8d55554-80f6-4c5a-9acb-bbe83e2cda8c" } , { "score" : 0.003453439101576805 , "actionId" : "5525778e-5e16-42a7-9053-3c1d930fa217" } , { "score" : 0.00213561556302011 , "actionId" : "d3eb7878-467c-49b1-9ab5-90df78dd434b" } , { "score" : 0.00209353631362319 , "actionId" : "51ef6b11-b4be-4bbf-8f01-103db2b301c0" } , { "score" : 0.0018506842898204923 , "actionId" : "7e195403-5ba0-4ba2-bf22-512740ddc67d" } , { "score" : 0.0012863661395385861 , "actionId" : "caac01e9-de0f-425f-b8c9-0c12a0836118" } , { "score" : 0.0004095352196600288 , "actionId" : "721387b2-f183-4f90-bbc4-67ad66f39b2f" } , { "score" : 0.0003577047027647495 , "actionId" : "fe59b587-1a1c-4cfb-978c-7787e6dff2f8" } , { "score" : 0.0002576180559117347 , "actionId" : "43e4afcc-542b-4349-940b-8d3947acdeb0" } , { "score" : 0.00014049031597096473 , "actionId" : "9bbfa48c-7b66-4ace-97eb-10ade3585535" } , { "score" : 0.00003773712887777947 , "actionId" : "0c919378-06a8-4867-a5ea-00f1cd2f8f57" } ] , "unscoredActions" : [ ] } } ] } ] , "definitions" : null , "initialFilledEntities" : [ ] , "tags" : [ ] , "description" : "" } as any ; test ( 'confirm item is found tree' , ( ) => { const treeUtils = new TreeUtils ( [ trainDialog1 , trainDialog2 , trainDialog3 ] , [ ] ) ; expect ( treeUtils . isInTree ( trainDialog1 ) ) . toEqual ( true ) ; const treeUtils2 = new TreeUtils ( [ trainDialog1 , trainDialog2 , trainDialog4 ] , [ ] ) ; expect ( treeUtils2 . isInTree ( trainDialog4 ) ) . toEqual ( true ) ; } ) ; test ( 'confirm item is not found in tree' , ( ) => { const treeUtils = new TreeUtils ( [ trainDialog1 , trainDialog2 , trainDialog3 ] , [ ] ) ; expect ( treeUtils . isInTree ( trainDialog4 ) ) . toEqual ( false ) ; const treeUtils2 = new TreeUtils ( [ trainDialog1 , trainDialog2 , trainDialog4 ] , [ ] ) ; expect ( treeUtils2 . isInTree ( trainDialog3 ) ) . toEqual ( false ) ; } ) ; } ) ; } ) ;