/*global describe, before, after, it*/
var targetMap = require('../lib/fetch/createOperationCollection'),
    writeOperation = require('../lib/fetch/writeOperation'),
    assert = require('assert'),
    fs = require('fs'),
    wrench = require('wrench'),
    tmp = 'test_fetch-writeOperation/';


var origin = './',
    resource;

resource = {
    target: {
        'lib/': tmp,
        '*.json': tmp
    }
};


describe('fetch/writeOperation', function(){
    before(function(){
        fs.mkdirSync(tmp);
    });

    after(function(){
        wrench.rmdirSyncRecursive(tmp);
    });


    it('should perform all write operations', function( done ){
        this.timeout(10000);
        targetMap( origin, resource, function( err, map ){
            assert.equal( err, null );
            writeOperation( map, function( err, destinations ){
                assert.equal( err, null );
                assert.ok( Array.isArray(destinations) );
                assert.ok( destinations.length > 1 );
                done();
            });
        });
    });
});

@@ -212,24 +212,30 @@
 uire('fs
+-extra
 '),%0A    
 wrench =
@@ -226,21 +226,19 @@
 '),%0A    
-wrenc
+pat
 h = requ
@@ -242,21 +242,19 @@
 equire('
-wrenc
+pat
 h'),%0A   
@@ -260,16 +260,29 @@
   tmp = 
+path.resolve(
 'test_fe
@@ -299,18 +299,18 @@
 peration
-/
 '
+)
 ;%0A%0A%0Avar 
@@ -558,33 +558,21 @@
     
-wrench.rmdirSyncRecursive
+fs.removeSync
 (tmp
@@ -732,24 +732,24 @@
 err, map )%7B%0A
-
             
@@ -767,32 +767,138 @@
 l( err, null );%0A
+            assert.ok(map.length %3E 20);%0A            assert.ok(map%5B0%5D.destination.indexOf(path.sep) %3E= 0);%0A
             writ

improve fetch-writeOperation test