diff --git a/test/testDir.js b/test/testDir.js index 199a4c2..1b0e682 100644 --- a/test/testDir.js +++ b/test/testDir.js @@ -5,6 +5,7 @@ var lodash = require('lodash'); var path = require('path'); +var fs = require('fs-extra'); var assert = require('assert'); var utils = require('./utils.js'); @@ -21,24 +22,24 @@ var dir = require('../src/dir.js'); * /level-2 * - two.html */ +function createFiles() { + // Create fake directory and files + var listFile = [ + './zero.html', + './three.html', + './level-1/one.html', + './level-1/level-2/two.html' + ]; + + lodash.forEach(listFile, function(file) { + utils.createFile(file, 'test'); + }); +} describe('Compiler Module:', function() { beforeEach(function(done) { utils.createContainer(function() { - - // Create fake directory and files - var listFile = [ - './zero.html', - './three.html', - './level-1/one.html', - './level-1/level-2/two.html' - ]; - - lodash.forEach(listFile, function(file) { - utils.createFile(file, 'test'); - }); - return done(); }); }); @@ -49,10 +50,12 @@ describe('Compiler Module:', function() { }); }); - describe('getFileList() test', function() { + describe('fileList() test', function() { it('should return list of file based on source dir', function(done) { + createFiles(); + dir.fileList('./', [], function(files) { assert.deepEqual(files, [ 'level-1/level-2/two.html', @@ -67,6 +70,8 @@ describe('Compiler Module:', function() { it('should return list of file based on source dir and also ignore list', function(done) { + createFiles(); + dir.fileList('./', ['./level-1/**/*'], function(files) { assert.deepEqual(files, [ 'three.html', @@ -79,4 +84,18 @@ describe('Compiler Module:', function() { }); + describe('clean() test', function() { + + it('should be clean all files inside the folder', function() { + + createFiles(); + var dirPath = process.cwd(); + + dir.clean(dirPath); + + assert.deepEqual([], fs.readdirSync(dirPath)); + }); + + }); + }); \ No newline at end of file