added tests
This commit is contained in:
parent
c2674863e9
commit
8097eb52bd
8 changed files with 74 additions and 1 deletions
72
tests/copydirsync_unix.js
Normal file
72
tests/copydirsync_unix.js
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
var testCase = require('nodeunit').testCase;
|
||||||
|
var fs = require('fs');
|
||||||
|
var wrench = require('../lib/wrench');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
function checkResultHidden(test, files) {
|
||||||
|
var check = [
|
||||||
|
'.hidden',
|
||||||
|
'.hidden.txt',
|
||||||
|
'bar.txt',
|
||||||
|
'foo',
|
||||||
|
path.join('.hidden', 'dolor.md'),
|
||||||
|
path.join('foo', 'bar'),
|
||||||
|
path.join('foo', 'dolor.md'),
|
||||||
|
path.join('foo', 'lorem.txt'),
|
||||||
|
path.join('foo', 'bar', 'ipsum.js')
|
||||||
|
];
|
||||||
|
|
||||||
|
test.deepEqual(files, check);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkResultShown(test, files) {
|
||||||
|
var check = [
|
||||||
|
'bar.txt',
|
||||||
|
'foo',
|
||||||
|
path.join('foo', 'bar'),
|
||||||
|
path.join('foo', 'dolor.md'),
|
||||||
|
path.join('foo', 'lorem.txt'),
|
||||||
|
path.join('foo', 'bar', 'ipsum.js')
|
||||||
|
];
|
||||||
|
|
||||||
|
test.deepEqual(files, check);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = testCase({
|
||||||
|
test_copyDirSyncRecursiveHidden: function(test) {
|
||||||
|
var dir = path.join(__dirname, 'shown');
|
||||||
|
var testdir = path.join(__dirname, 'testdir');
|
||||||
|
|
||||||
|
test.ok(path.existsSync(dir), 'Folders should exist');
|
||||||
|
|
||||||
|
wrench.mkdirSyncRecursive(testdir, 0777);
|
||||||
|
wrench.copyDirSyncRecursive(dir, testdir, { excludeHidden: false });
|
||||||
|
|
||||||
|
var files = wrench.readdirSyncRecursive(testdir);
|
||||||
|
|
||||||
|
checkResultHidden(test, files);
|
||||||
|
|
||||||
|
wrench.rmdirSyncRecursive(testdir);
|
||||||
|
|
||||||
|
test.done();
|
||||||
|
},
|
||||||
|
test_copyDirSyncRecursiveShown: function(test) {
|
||||||
|
var dir = path.join(__dirname, 'shown');
|
||||||
|
var testdir = path.join(__dirname, 'testdir');
|
||||||
|
|
||||||
|
test.ok(path.existsSync(dir), 'Folders should exist');
|
||||||
|
|
||||||
|
wrench.mkdirSyncRecursive(testdir, 0777);
|
||||||
|
wrench.copyDirSyncRecursive(dir, testdir, { excludeHidden: true });
|
||||||
|
|
||||||
|
var files = wrench.readdirSyncRecursive(testdir);
|
||||||
|
|
||||||
|
checkResultShown(test, files);
|
||||||
|
|
||||||
|
wrench.rmdirSyncRecursive(testdir);
|
||||||
|
|
||||||
|
test.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// vim: et ts=4 sw=4
|
||||||
|
|
@ -3,5 +3,6 @@
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
group_mkdir: require('./mkdir'),
|
group_mkdir: require('./mkdir'),
|
||||||
group_readdir: require('./readdir')
|
group_readdir: require('./readdir'),
|
||||||
|
group_copydir: require('./copydirsync_unix')
|
||||||
};
|
};
|
||||||
|
|
|
||||||
0
tests/shown/.hidden.txt
Normal file
0
tests/shown/.hidden.txt
Normal file
0
tests/shown/.hidden/dolor.md
Normal file
0
tests/shown/.hidden/dolor.md
Normal file
0
tests/shown/bar.txt
Normal file
0
tests/shown/bar.txt
Normal file
0
tests/shown/foo/bar/ipsum.js
Normal file
0
tests/shown/foo/bar/ipsum.js
Normal file
0
tests/shown/foo/dolor.md
Normal file
0
tests/shown/foo/dolor.md
Normal file
0
tests/shown/foo/lorem.txt
Normal file
0
tests/shown/foo/lorem.txt
Normal file
Reference in a new issue