var assert = require('assert');

var f_ = require(__dirname + './../../index.js'),
    TaskList = require('./../lib/TaskList.js');


describe('events', function (){

  describe('#onFinish', function (){
    it('should be able to finish the task with no onFinish (using timeout to check)', function (done){

      var taskList = f_.setup( new (f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      })) );

      taskList.onFinish = undefined;

      taskList.start();

      setTimeout(function (){
        assert.equal(taskList.f_status, 'finished');
        done();
      }, 125);

    });
  });

  describe('#onAbort', function (){
    it('should be able to abort the task with no onAbort (using timeout to check)', function (done){

      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = new TaskList({ abort: true });
      taskList = f_.setup(taskList);
      taskList.onAbort = undefined;
      taskList.start();

      setTimeout(function (){
        assert.equal(taskList.f_status, 'aborted');
        done();
      }, 125);

    });



  });


  describe('#onNext', function (){

    it('should call onNext and give it functionFlow info', function (done){

      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = new TaskList();
      taskList = f_.setup(taskList);
      taskList.onNext = function (info){
        if(info.f_i === TaskList.prototype.f_functionFlow.length) done();
      }
      taskList.start();
    });

    it('should be able to call f_next with no onNext (using timeout to check)', function (done){

      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = new TaskList();
      taskList = f_.setup(taskList);
      taskList.onNext = undefined;
      taskList.onFinish = done;
      taskList.start();
    });

  });


/*
  describe('#onRetryAll', function (){

    it('should call onRetryAll ', function (done){

      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = f_.setup(new TaskList({ retryAllOnce: true }));
      taskList.onRetryAll = done;
      taskList.start();
    });

    it('should be able to `retryAll` with no onRetryAll', function (done){

      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = new TaskList({ retryAllOnce: true });
      taskList = f_.setup(taskList);
      taskList.onRetryAll = undefined;
      taskList.onFinish = done;
      taskList.start();
    });
  });

  describe('#onRetryThis', function (){

    it('should call onRetryThis', function (done){
      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = f_.setup(new TaskList({ retryThis: true }));
      taskList.onRetryThis = done;
      taskList.start();
    });

    it('should be able to `retryThis` with no onRetryAll', function (done){
      TaskList = f_.augment(TaskList, {
        functionFlow: ['getSource', 'writeSource', 'notify']
      });

      var taskList = new TaskList({ retryThis: true });
      taskList = f_.setup(taskList);
      taskList.onRetryThis = undefined;
      taskList.onFinish = done;
      taskList.start();
    });

  });
*/

});
@@ -2011,10 +2011,8 @@
 ;%0A%0A%0A
-/*
 %0A  d
@@ -2075,20 +2075,43 @@
  onRetry
-All 
+ and give us an info object
 ', funct
@@ -2330,18 +2330,96 @@
 etry
-All = done
+ = function (info)%7B%0A        assert.equal(typeof info, 'object');%0A        done();%0A      %7D
 ;%0A  
@@ -2493,35 +2493,32 @@
  with no onRetry
-All
 ', function (don
@@ -2752,19 +2752,16 @@
 .onRetry
-All
  = undef
@@ -2901,28 +2901,48 @@
 call onRetry
-This
+ and give an info object
 ', function 
@@ -3153,19 +3153,96 @@
 etry
-This = done
+ = function (info)%7B%0A        assert.equal(typeof info, 'object');%0A        done();%0A      %7D
 ;%0A  
@@ -3321,27 +3321,24 @@
 h no onRetry
-All
 ', function 
@@ -3572,20 +3572,16 @@
 .onRetry
-This
  = undef

Test for current code complete