var assert=require("assert"),path=require("path"),rimraf=require("rimraf"),readDirFiles=require("read-dir-files"),ncp=require("../").ncp,fixtures=path.join(__dirname,"fixtures"),src=path.join(fixtures,"src"),out=path.join(fixtures,"out");describe("ncp",function(){before(function(r){rimraf(out,function(){ncp(src,out,r)})});describe("when copying a directory of files",function(){it("files are copied correctly",function(r){readDirFiles(src,"utf8",function(e,i){readDirFiles(out,"utf8",function(t,n){assert.ifError(e);assert.deepEqual(i,n);r()})})})});describe("when copying files using filter",function(){before(function(r){var e=function(r){return"a"!=r.substr(r.length-1)};rimraf(out,function(){ncp(src,out,{filter:e},r)})});it("files are copied correctly",function(r){readDirFiles(src,"utf8",function(e,i){function t(r){for(var e in r){var i=r[e];if(i instanceof Object)return t(i);"a"==e.substr(e.length-1)&&delete r[e]}}t(i);readDirFiles(out,"utf8",function(e,t){assert.ifError(e);assert.deepEqual(i,t);r()})})})});describe("when using clobber=false",function(){it("the copy is completed successfully",function(r){ncp(src,out,function(){ncp(src,out,{clobber:!1},function(e){assert.ifError(e);r()})})})});describe("when using transform",function(){it("file descriptors are passed correctly",function(r){ncp(src,out,{transform:function(r,e,i){assert.notEqual(i.name,void 0);assert.strictEqual(typeof i.mode,"number");r.pipe(e)}},r)})})});