fs.js
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*global casper*/
/*jshint strict:false*/
var fs = require('fs'), t = casper.test;
// Testing added methods
(function() {
t.comment('fs.dirname()');
var tests = {
'/local/plop/foo.js': '/local/plop',
'local/plop/foo.js': 'local/plop',
'./local/plop/foo.js': './local/plop',
'c:\\local\\plop\\foo.js': 'c:/local/plop',
'D:\\local\\plop\\foo.js': 'D:/local/plop',
'D:\\local\\plop\\': 'D:/local/plop',
'c:\\': 'c:',
'c:': 'c:'
};
for (var testCase in tests) {
t.assertEquals(fs.dirname(testCase), tests[testCase], 'fs.dirname() does its job for ' + testCase);
}
})();
(function() {
t.comment('fs.dirname()');
var tests = {
'/': false,
'/local/plop/foo.js': false,
'D:\\local\\plop\\': true,
'c:\\': true,
'c:': true,
'\\\\Server\\Plop': true
};
for (var testCase in tests) {
t.assertEquals(fs.isWindows(testCase), tests[testCase], 'fs.isWindows() does its job for ' + testCase);
}
})();
t.done(14);