var expect = require("chai").expect;
var sinon = require("sinon");
var Q = require('q');

var rewire = require("rewire");

var createDirectoryObject = rewire('../src/createDirectoryObject');

describe("createDirectoryObject", function(){

	beforeEach(function(){
		// Make sure fs methods are always empty by default
		createDirectoryObject.__set__( 'stat', function( currentDir ){} );
	});

	it("should not have children if file", function( done ){

		var statStub = sinon.stub().returns( Q.resolve({
			isFile: function(){
				return true;
			}
		}));

		createDirectoryObject.__set__( 'stat', statStub );

		var path = "./fakeFile.txt";
		createDirectoryObject( path, "" ).then( function( data ){
			expect( data.childrend ).to.be.undefined;
			done();
		});
	});
});
@@ -384,50 +384,153 @@
 );%0A%09
-%7D);%0A%0A%09it(%22should not have children if file
+%09createDirectoryObject.__set__( 'readdir', function( currentDir )%7B%7D );%0A%09%7D);%0A%0A%09describe(%22file%22, function()%7B%0A%0A%09%09it(%22should resolve with no children
 %22, f
@@ -547,16 +547,17 @@
 one )%7B%0A%0A
+%09
 %09%09var st
@@ -599,16 +599,17 @@
 solve(%7B%0A
+%09
 %09%09%09isFil
@@ -627,16 +627,17 @@
 ()%7B%0A%09%09%09%09
+%09
 return t
@@ -648,18 +648,20 @@
 %0A%09%09%09
+%09
 %7D%0A
+%09
 %09%09%7D));%0A%0A
 %09%09cr
@@ -656,16 +656,17 @@
 %09%09%7D));%0A%0A
+%09
 %09%09create
@@ -713,16 +713,17 @@
 b );%0A%0A%09%09
+%09
 var path
@@ -743,16 +743,17 @@
 e.txt%22;%0A
+%09
 %09%09create
@@ -804,16 +804,17 @@
 data )%7B%0A
+%09
 %09%09%09expec
@@ -829,17 +829,16 @@
 children
-d
  ).to.be
@@ -840,16 +840,748 @@
 to.be.un
+defined;%0A%09%09%09%09done();%0A%09%09%09%7D);%0A%09%09%7D);%0A%0A%09%7D);%0A%0A%09describe(%22directory%22, function()%7B%0A%0A%09%09it(%22should resolve with children%22, function( done )%7B%0A%0A%09%09%09var path = %22./fakeDir%22;%0A%09%09%09var files = %5B%0A%09%09%09%09%22fakeFile1%22,%0A%09%09%09%09%22fakeFile2%22,%0A%09%09%09%09%22fakeFile3%22%0A%09%09%09%5D;%0A%0A%09%09%09var statStub = sinon.stub();%0A%09%09%09statStub.onCall(0).returns( Q.resolve(%7B%0A%09%09%09%09isFile: function()%7B%0A%09%09%09%09%09return false;%0A%09%09%09%09%7D%0A%09%09%09%7D));%0A%0A%09%09%09statStub.returns( Q.resolve(%7B%0A%09%09%09%09isFile: function()%7B%0A%09%09%09%09%09return true;%0A%09%09%09%09%7D%0A%09%09%09%7D));%0A%0A%09%09%09var readdirStub = sinon.stub().returns( Q.resolve( files ));%0A%0A%09%09%09createDirectoryObject.__set__( 'stat', statStub );%0A%09%09%09createDirectoryObject.__set__( 'readdir', readdirStub );%0A%0A%09%09%09createDirectoryObject( path, %22%22 ).then( function( data )%7B%0A%09%09%09%09expect( data.children ).to.be.
 defined;
@@ -1581,16 +1581,17 @@
 efined;%0A
+%09
 %09%09%09done(
@@ -1595,20 +1595,28 @@
 ne();%0A%09%09
+%09
 %7D);%0A
+%09%09%7D);%0A%0A
 %09%7D);%0A%7D);

Add tests