All files / botbuilder-unit/spec customValidationStepSpec.js

77.42% Statements 24/31
100% Branches 0/0
56.25% Functions 9/16
77.42% Lines 24/31
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 691x 1x   1x 1x   1x 3x 3x   2x 2x 2x 2x   2x                                             1x 1x 1x     1x     1x 1x 1x         1x     1x 1x 1x         1x          
const botFactory = require('./lib/botFactory');
const unit = require('../');
 
describe('Test sugar proposed by the Library', function () {
  let bot = null;
 
  beforeEach(()=> {
    bot = botFactory();
    bot.dialog('/test', [
      function (session) {
        session.send('message #0');
        session.send('message #1');
        session.send('message #2');
        session.send('message #3');
 
        session.endConversation('message #4');
      }
    ]);
  });
  function itCallback(title, path) {
    return (done) => {
      let script = require(path);
      unit(bot, script, {
        title: title
      }).then(function () {
        done();
      });
    }
  }
 
  function myIt(title, path) {
    it(title, itCallback(title, path))
  }
 
  function fmyIt(title, path) {
 
  }
 
  it('Test custom step inside script', ( done ) => {
    let script = require('./scripts/custom/customStepScript.js');
    unit(bot, script, {
      title: 'Test custom step inside script'
    }).then(function () {
      done();
    });
  })
  it('Test that custom step MUST return a promise', ( done ) => {
    let script = require('./scripts/custom/notAPromiseScript.js');
    unit(bot, script, {
      title: 'Test custom step inside script'
    }).then(function () {
      fail('Impossible case')
    }, () => {
      done();
    });
  })
  it('Test that custom could failure whole script', ( done ) => {
    let script = require('./scripts/custom/customFailureScript');
    unit(bot, script, {
      title: 'Test that custom could failure whole script'
    }).then(function () {
      fail('Impossible case')
    }, () => {
      done();
    });
  })
 
 
});