<commit_before>/*jshint expr: true*/
"use strict";
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
var mockHelper = require("./helpers/mock_helper");
chai.use(chaiAsPromised);
var expect = chai.expect;
chai.config.includeStack = true;

describe("Alexa", function() {
  var Alexa = require("../index");
  describe("app", function() {
    var app = new Alexa.app("myapp");
    describe("#request", function() {
      describe("cards response", function() {
        var mockRequest = mockHelper.load("intent_request_airport_info.json");
        context("with an intent request of airportInfoIntent", function() {
          var app = new Alexa.app("myapp");
          var intentHandler = function(req, res) {
            res.say(expectedMessage);
            return true;
          };
          var expectedMessage = "tubular!";
          app.intent("airportInfoIntent", {
            "slots": {
              "AIRPORTCODE": "FAACODES"
            },
            "utterances": ["{|flight|airport} {|delay|status} {|info} {|for} {-|AIRPORTCODE}"]
          }, intentHandler);

          describe("intent handler with card and say function called", function() {
            it("responds with a speech and card", function() {
              app = new Alexa.app("myapp");
              var cardTitle = "radCard";
              var cardContent = "MyCard Content!";
              intentHandler = function(req, res) {
                res.say(expectedMessage).card(cardTitle, cardContent);
                return true;
              };
              app.intent("airportInfoIntent", {
                "slots": {
                  "AIRPORTCODE": "FAACODES"
                },
                "utterances": ["{|flight|airport} {|delay|status} {|info} {|for} {-|AIRPORTCODE}"]
              }, intentHandler);
              var subject = app.request(mockRequest);
              var alexaResponse = subject.then(function(response) {
                return response.response.outputSpeech;
              });
              var cardResponse = subject.then(function(response) {
                return response.response.card;
              });
              return Promise.all([
                expect(alexaResponse).to.eventually.become({
                  ssml: "<speak>" + expectedMessage + "</speak>",
                  type: "SSML"
                }),
                expect(cardResponse).to.eventually.become({
                  "content": "MyCard Content!",
                  "title": "radCard",
                  "type": "Simple"
                }),
              ]);
            //return expect(subject).to.eventually.become({
            //});
            });
          });
        });
      });
    });
  });
});<commit_msg>adds test for account link<commit_after>/*jshint expr: true*/
"use strict";
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
var mockHelper = require("./helpers/mock_helper");
chai.use(chaiAsPromised);
var expect = chai.expect;
chai.config.includeStack = true;

describe("Alexa", function() {
  var Alexa = require("../index");
  describe("app", function() {
    var app = new Alexa.app("myapp");
    var setupIntentHandler = function(handlerFunction) {
      app = new Alexa.app("myapp");
      app.intent("airportInfoIntent", {}, handlerFunction);
    };

    describe("#request", function() {
      describe("cards response", function() {
        var mockRequest = mockHelper.load("intent_request_airport_info.json");
        context("with an intent request of airportInfoIntent", function() {
          var intentHandler = function(req, res) {
            res.say(expectedMessage);
            return true;
          };
          setupIntentHandler(intentHandler);
          var expectedMessage = "tubular!";

          describe("intent handler with AccountLink called on res", function() {
            it("responds with a account link card", function() {
              intentHandler = function(req, res) {
                res.linkAccount();
              };
              setupIntentHandler(intentHandler);
              var subject = app.request(mockRequest);
              var cardResponse = subject.then(function(response) {
                return response.response.card;
              });
              return expect(cardResponse).to.eventually.become({
                "type": "LinkAccount"
              });
            });
          });
          describe("intent handler with card and say function called on res", function() {
            it("responds with a speech and card", function() {
              var cardTitle = "radCard";
              var cardContent = "MyCard Content!";
              intentHandler = function(req, res) {
                res.say(expectedMessage).card(cardTitle, cardContent);
                return true;
              };
              setupIntentHandler(intentHandler);
              var subject = app.request(mockRequest);
              var alexaResponse = subject.then(function(response) {
                return response.response.outputSpeech;
              });
              var cardResponse = subject.then(function(response) {
                return response.response.card;
              });
              return Promise.all([
                expect(alexaResponse).to.eventually.become({
                  ssml: "<speak>" + expectedMessage + "</speak>",
                  type: "SSML"
                }),
                expect(cardResponse).to.eventually.become({
                  "content": "MyCard Content!",
                  "title": "radCard",
                  "type": "Simple"
                }),
              ]);
            });
          });
        });
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.13257443082311735, 'fraction_numerical': 0.0, 'mean_word_length': 1.8133004926108374, 'pattern_counts': {'":': 13, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2986164', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1434, 'n_words': 311}