'use strict';

var jf = require('../../'),
    expect    = require('chai').expect;

const testFilePath = './' + Math.random() + '.json';

const copyFilePath1 = './' + Math.random() + '.json';
const copyFilePath2 = './' + Math.random() + '.json';

var testValue1 = { msg: "test value 1" };
var testValue2 = { msg: "test value 2" };

describe('Chained operation ', function () {
  it('can be branched.', function (done) {

    let init =
      jf.filed( testFilePath )
      .io( function( obj, filePath){} )
      .pass( function(){

        let rootPart =
          jf.filed( testFilePath );

        rootPart
        .copy( function(){ return copyFilePath1; }, function( err ){ console.log(err) } )
        .io( function( obj, filePath ) { return testValue1; } )
        .pass( function( obj, filePath ){
          expect( obj ).to.eql( testValue1 );
        } ).exec();

        rootPart
        .copy( function(){ return copyFilePath2; }, function( err ){ console.log(err) } )
        .io( function( obj, filePath ) { return testValue2; } )
        .pass( function( obj, filePath ){
          expect( obj ).to.eql( testValue2 );
        } ).exec();


      })
      .exec();

    setTimeout(
      function() {
        done();
      },
      100
    );


  });
});

@@ -135,117 +135,8 @@
 ';%0A%0A
-const copyFilePath1 = './' + Math.random() + '.json';%0Aconst copyFilePath2 = './' + Math.random() + '.json';%0A%0A
 var 
@@ -474,36 +474,19 @@
 lePath )
-;%0A
 %0A  
-      rootPart%0A
         
@@ -515,21 +515,38 @@
 urn 
-copyFilePath1
+'./' + Math.random() + '.json'
 ; %7D,
@@ -575,32 +575,50 @@
 ole.log(err) %7D )
+%0A%0A        rootPart
 %0A        .io( fu
@@ -796,98 +796,8 @@
 art%0A
-        .copy( function()%7B return copyFilePath2; %7D, function( err )%7B console.log(err) %7D )%0A
     

make test of execution plan more interesting