All files / botbuilder-unit/spec StandaloneDialogSpec.js

57.14% Statements 12/21
0% Branches 0/4
50% Functions 3/6
57.14% Lines 12/21
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 44 451x   1x 1x 1x           1x 1x               1x   1x 1x           1x 1x                         1x    
const unit = require('../');
 
describe('Standalone dialogs, ', function () {
  it('test that function will be treated as dialog', (done) => {
    let script = [
      {user: 'hi!'},
      {bot: 'hello'},
      {user: 'say something'},
      {bot: 'Hello World!'}
    ]
    let attempt = 0;
    let dialog = function (session) {
      if (!attempt) {
        attempt++;
        session.endDialog('hello');
      } else {
        session.endDialog('Hello World!');
      }
    }
    unit(dialog, script).then(done);
  })
  it('test with array, library treats it as a dialog', (done) => {
    let script = [
      {user: 'hi!'},
      {bot: 'hello'},
      {user: 'say something'},
      {bot: 'Hello World!'}
    ]
    let attempt = 0;
    let dialog = [
      (session,args, next) => {
        if (!attempt) {
          attempt++;
          session.endDialog('hello');
        } else {
          next();
        }
      },
      (session) => {
        session.endDialog('Hello World!');
      }
    ]
    unit(dialog, script).then(done);
  });
})