Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botkit-mock

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botkit-mock

Write tests for botkit.

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36
decreased by-29.41%
Maintainers
1
Weekly downloads
 
Created
Source

README

Botkit-Mock - Write tests for Botkit.

Setup

  1. npm install --save botkit-mock
  2. Require botkit-mock in your test: ie const mock = require('botkit-mock');
  3. If testing a controller, require your controller in your test: ie const fileBeingTested = require("../controllers/indexController")
  4. Follow test case examples seen here

Basic Usage

Testing Controllers

In your beforeEach, setup a mock controller and pass it to fileBeingTested.

const assert = require('assert');
const mock = require('botkit-mock');
const fileBeingTested = require("../indexController");

describe("controller tests",()=>{
    beforeEach((done)=>{
        var self = this;
        self.slackId = 'some id'
        self.userName = 'some username'
        self.controller = new mock.controller()
        fileBeingTested(self.controller.bot,self.controller)
        done();
    });

In your it statement, use the controller.usersInput method to define the conversation.

    it('should return hello', (done)=>{
        var self = this;
        return self.controller.usersInput([{
            type: null,
            first:true,
            messages:[{text: 'quick', isAssertion:true}]
        }]).then((text)=>{
            assert.equal(text, 'hello')
            done();
        })
    });
});

Options

You can specify options to usersInput.

first - indicates which user spoke first in multi-user testing.

deep - indicates the index of the conversation response to return in .then(). 0 is the last response, 1 is the second-to-last, etc..

isAssertion - indicates which conversation response array to return in .then() in multi-user testing.

Testing API

See examples here.

Built by the team at https://www.gratify.chat.

Keywords

FAQs

Package last updated on 26 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc