0.1.5 • Published 7 years ago

botkit-testing v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

BotkitTesting - For building test to botkit bots

For now is experimental

##Example of conversation

module.exports = function(bot, controller){
  controller.hears(['hello'], 'direct_message', function(bot, message){
    bot.reply(message, 'hello human');
  });

  controller.hears('hi bot',['direct_message','direct_mention','mention'], (bot,message) => {
    bot.startConversation(message, (err,convo) => {
      convo.say('hi human');
      convo.ask('How are you?', [
        {
          default: true,
          callback: function(response,convo) {
            convo.next();
          }
        }
      ]);
      convo.on('end', (convo) => {
        if (convo.status == 'completed') {
          bot.reply(message, 'fine thanks');
        }
      });
    });
  });
};

##Example of test

const botMock = require('botkit-testing').create();
const testedFile = require("../src/bots/simple");
const assert = require('assert');

describe("simple controller",() => {
  beforeEach((done) => {
    testedFile(botMock.bot, botMock.controller);
    done();
  });

  it('hello', (done) => {
    botMock.testRunner
      .human('hello')
      .bot('hello human')
      .start(done)
    ;
  });

  it('hi bot', (done) => {
    botMock.testRunner
      .human('hi bot')
      .bot('hi human')
      .bot('How are you?')
      .human('fine thanks you, and you?')
      .bot('fine thanks')
      .start(done)
    ;
  });
});
0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago