MockConversation

Testing. MockConversation

Extension for the main Conversation class with testing conveniences.

Constructor

new MockConversation()

Source:
Example
const Testing = require('@oracle/bots-node-sdk/testing');
const { MyCustomComponent } = require('path/to/custom/components');

describe('MyCustomComponent', () => {
  it('should reply with message', done => {
    const request = Testing.MockRequest();
    const conversation = Testing.MockConversation.fromRequest(request);
    new MyCustomComponent()
      .invoke(conversation, err => {
        expect(conversation.response().messages).toBeDefined();
        return err ? done.fail(err) : done();
      });
  })
})

Methods

(static) any()

Source:
create a mock conversation with an "empty" valid request.
Returns:
Conversation

(static) fromRequest(req)

Source:
create conversation instance from a request
Parameters:
Name Type Description
req * the component invocation request body
Returns:
Conversation

getReplies()

Source:
get conversation reply messages
Returns:
- message list returned by the component