All files / botbuilder-unit/spec proactiveMessagesSpec.js

95.45% Statements 21/22
100% Branches 0/0
100% Functions 5/5
95.45% Lines 21/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 441x 1x 1x 1x 1x   1x 1x 1x 1x 1x     1x 1x 1x 1x 1x   1x           1x     1x 1x         1x           1x      
const builder = require('botbuilder');
const botFactory = require('./lib/botFactory');
const unit = require('../');
describe('Timeout test suite', function () {
  let bot = null;
 
  let sendProactiveMessage = (address) => {
    var msg = new builder.Message().address(address);
    msg.text('hi!');
    msg.textLocale('en-US');
    bot.send(msg);
  }
 
  beforeEach((done) => {
    try {
      jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
      bot = botFactory();
      bot.dialog('/test', [
        (session, args, next) => {
          session.endDialog('End of test dialog')
        }
      ])
    } catch (e) {
      fail(e);
    }
    done();
  });
 
  it('Test that proactive messages supported', (done) => {
    let script = [
      {bot: "hi!"},
      {user: "hi"},
      {bot: 'End of test dialog'}
    ]
    unit(bot, script, {
      timeout: 1000,
      title: 'Should support `timeout` field, will fail if timeout exceeded'
    })
      .then(done)
      .catch(done);
    sendProactiveMessage(unit.DEFAULT_ADDRESS);
  });
 
})