'use strict';
// tests for witAiHandler
// Generated by serverless-mocha-plugin

const mod               = require('../wit-ai/handler.js');
const mochaPlugin       = require('serverless-mocha-plugin');
const lambdaWrapper     = mochaPlugin.lambdaWrapper;
const expect            = mochaPlugin.chai.expect;
const env               = require('dotenv').config();

const liveFunction = {
  region: process.env.SERVERLESS_REGION,
  lambdaFunction: process.env.SERVERLESS_PROJECT + '-witAiHandler'
};

const wrapped = lambdaWrapper.wrap(mod, { handler: 'handler' });

describe('witAiHandler', () => {
  before(function (done) {
//  lambdaWrapper.init(liveFunction); // Run the deployed lambda

    done();
  });

  it('Check weather', (done) => {
    const snsEvent = {
      id: Math.round(Math.random()*10000),
      updated: Date.now(),
      sender: { 
        id: process.env.FACEBOOK_ID_FOR_TESTS,
        name: 'John Smith' 
      },
      message: { text: "What is the weather in Rome?"}
    }
    wrapped.run({ Records:
      [ { EventSource: 'aws:sns',
          EventVersion: '1.0',
          EventSubscriptionArn: 'arn:aws:sns:us-east-1:869231578214:sc5-serverless-messenger-bot-witAiTopic-dev:9752702a-cfd3-4711-b0c1-eda9f5f87635',
          Sns: {
            Subject: 'SUBJECT',
            Message: JSON.stringify(snsEvent,null)
          }
      } ] 
    }, (err, response) => {
      if (err) {
        return done(err);
      }
      expect(response.text).to.match(/[a-z]+/i);
      done();
    });
  });
});

'use strict';
// tests for witAiHandler
// Generated by serverless-mocha-plugin

const mod               = require('../wit-ai/handler.js');
const mochaPlugin       = require('serverless-mocha-plugin');
const lambdaWrapper     = mochaPlugin.lambdaWrapper;
const expect            = mochaPlugin.chai.expect;
const env               = require('dotenv').config();

const liveFunction = {
  region: process.env.SERVERLESS_REGION,
  lambdaFunction: process.env.SERVERLESS_PROJECT + '-witAiHandler'
};

const wrapped = lambdaWrapper.wrap(mod, { handler: 'handler' });

describe('witAiHandler', () => {
  before(function (done) {
//  lambdaWrapper.init(liveFunction); // Run the deployed lambda

    done();
  });

  it('Send text to Wit.ai and receive a response', (done) => {
    const snsEvent = {
      id: Math.round(Math.random()*10000),
      updated: Date.now(),
      sender: { 
        id: process.env.FACEBOOK_ID_FOR_TESTS,
        name: 'John Smith' 
      },
      message: { text: "What is the weather in Rome?"}
    }
    wrapped.run({ Records:
      [ { EventSource: 'aws:sns',
          EventVersion: '1.0',
          EventSubscriptionArn: 'arn:aws:sns:us-east-1:869231578214:sc5-serverless-messenger-bot-witAiTopic-dev:9752702a-cfd3-4711-b0c1-eda9f5f87635',
          Sns: {
            Subject: 'SUBJECT',
            Message: JSON.stringify(snsEvent,null)
          }
      } ] 
    }, (err, response) => {
      if (err) {
        return done(err);
      }
      expect(response.text).to.match(/[a-z]+/i);
      done();
    });
  });
});

Fix witAi test name