Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added more tests for basedir

  • Loading branch information...
commit fa31901420959101252c672f1cc6315496dae943 1 parent 5d4e692
mde authored
Showing with 23 additions and 3 deletions.
  1. +0 −1  lib/file.js
  2. +23 −2 test/file.js
View
1  lib/file.js
@@ -416,7 +416,6 @@ var fileUtils = new (function () {
if (!basedir) {
basedir = '.';
}
- console.log(basedir);
// Strip trailing slashes
if (!(basedir == '\\' || basedir == '/')) {
basedir = basedir.replace(/\\$|\/$/, '');
View
25 test/file.js
@@ -160,6 +160,11 @@ tests = {
assert.equal('C:\\foo\\bar', file.basedir(p));
}
+, 'test basedir with Unix root path': function () {
+ var p = '/';
+ assert.equal('/', file.basedir(p));
+ }
+
, 'test basedir with Unix absolute path and double-asterisk': function () {
var p = '/**/foo/bar/baz';
assert.equal('/', file.basedir(p));
@@ -186,8 +191,24 @@ tests = {
}
, 'test basedir with leading dot-dot-slash and double-asterisk': function () {
- var p = '../test/**/*.js';
- assert.equal('../test', file.basedir(p));
+ var p = '../../test/**/*.js';
+ assert.equal('../../test', file.basedir(p));
+ }
+
+, 'test basedir with single-asterisk in dirname': function () {
+ var p = 'a/test*/file';
+ assert.equal('a', file.basedir(p));
+ }
+
+, 'test basedir with single filename': function () {
+ var p = 'filename';
+ assert.equal('.', file.basedir(p));
+ }
+
+, 'test basedir with empty path': function () {
+ var p = '';
+ assert.equal('.', file.basedir(p));
+ assert.equal('.', file.basedir());
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.