Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added more tests for basedir

  • Loading branch information...
commit fa31901420959101252c672f1cc6315496dae943 1 parent 5d4e692
Matthew Eernisse authored December 06, 2012

Showing 2 changed files with 23 additions and 3 deletions. Show diff stats Hide diff stats

  1. 1  lib/file.js
  2. 25  test/file.js
1  lib/file.js
@@ -416,7 +416,6 @@ var fileUtils = new (function () {
416 416
     if (!basedir) {
417 417
       basedir = '.';
418 418
     }
419  
-    console.log(basedir);
420 419
     // Strip trailing slashes
421 420
     if (!(basedir == '\\' || basedir == '/')) {
422 421
       basedir = basedir.replace(/\\$|\/$/, '');
25  test/file.js
@@ -160,6 +160,11 @@ tests = {
160 160
     assert.equal('C:\\foo\\bar', file.basedir(p));
161 161
   }
162 162
 
  163
+, 'test basedir with Unix root path': function () {
  164
+    var p = '/';
  165
+    assert.equal('/', file.basedir(p));
  166
+  }
  167
+
163 168
 , 'test basedir with Unix absolute path and double-asterisk': function () {
164 169
     var p = '/**/foo/bar/baz';
165 170
     assert.equal('/', file.basedir(p));
@@ -186,8 +191,24 @@ tests = {
186 191
   }
187 192
 
188 193
 , 'test basedir with leading dot-dot-slash and double-asterisk': function () {
189  
-    var p = '../test/**/*.js';
190  
-    assert.equal('../test', file.basedir(p));
  194
+    var p = '../../test/**/*.js';
  195
+    assert.equal('../../test', file.basedir(p));
  196
+  }
  197
+
  198
+, 'test basedir with single-asterisk in dirname': function () {
  199
+    var p = 'a/test*/file';
  200
+    assert.equal('a', file.basedir(p));
  201
+  }
  202
+
  203
+, 'test basedir with single filename': function () {
  204
+    var p = 'filename';
  205
+    assert.equal('.', file.basedir(p));
  206
+  }
  207
+
  208
+, 'test basedir with empty path': function () {
  209
+    var p = '';
  210
+    assert.equal('.', file.basedir(p));
  211
+    assert.equal('.', file.basedir());
191 212
   }
192 213
 
193 214
 };

0 notes on commit fa31901

Please sign in to comment.
Something went wrong with that request. Please try again.