{"size": 1402, "ext": "js", "max_stars_repo_path": "transcripts/tests/luis.test.js", "max_stars_repo_name": "stefangomez/botbuilder-js", "max_stars_repo_stars_event_min_datetime": "2019-05-09T12:20:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T16:37:55.000Z", "max_issues_repo_path": "transcripts/tests/luis.test.js", "max_issues_repo_name": "stefangomez/botbuilder-js", "max_issues_repo_issues_event_min_datetime": "2019-05-06T21:06:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:35:22.000Z", "max_forks_repo_path": "transcripts/tests/luis.test.js", "max_forks_repo_name": "stefangomez/botbuilder-js", "max_forks_repo_forks_event_min_datetime": "2019-05-10T15:35:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T17:25:34.000Z"}
{"max_stars_count": 345, "max_issues_count": 2931, "max_forks_count": 168, "avg_line_length": 37.8918918919, "max_line_length": 152, "alphanum_fraction": 0.7039942939}
const assert = require('assert');
const { LuisRecognizer } = require('botbuilder-ai');
const assertBotLogicWithTranscript = require('../../libraries/botbuilder-core/tests/transcriptUtilities').assertBotLogicWithBotBuilderTranscript;

var luisAppId = process.env['LUISAPPID_TRANSCRIPT'];
var luisSubscriptionKey = process.env['LUISAPPKEY_TRANSCRIPT'];
var luisUriBase = process.env['LUISURIBASE_TRANSCRIPT'];
var recognizer;

xdescribe(`LUIS Tests using transcripts`, function () {
    if (!luisAppId || !luisSubscriptionKey) {
        console.warn('* Missing LUIS Environment variables (LUISAPPID_TRANSCRIPT, LUISAPPKEY_TRANSCRIPT) - Skipping LUIS Tests');
        return;
    }

    recognizer = new LuisRecognizer({
        appId: luisAppId,
        subscriptionKey: luisSubscriptionKey,
        serviceEndpoint: luisUriBase
    });

    this.timeout(20000);

    it('LuisRecognizer Middleware', assertBotLogicWithTranscript('LuisTests/LuisMiddleware.chat', LuisTestLogic, (adapter) => adapter.use(recognizer)));
});

function LuisTestLogic(conversationState, userState) {
    return async (context) => {
        var luisResult = recognizer.get(context);
        var intent = LuisRecognizer.topIntent(luisResult);
        if (intent !== 'None') {
            await context.sendActivity(`intent:${intent}`);
        } else {
            await context.sendActivity('default message');
        }
    }
}