Skip to content

Commit

Permalink
Fix: Normalize test paths to work cross-platform (closes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokkabonna authored and phated committed Dec 28, 2018
1 parent 58d6c32 commit 0ea26fa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/findup-sync_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ exports['findup'] = {
'simple': function(test) {
test.expect(8);
var opts = {cwd: 'test/fixtures/a/b'};
test.equal(rel(findup('foo.txt', opts)), 'test/fixtures/a/foo.txt', 'should find files');
test.equal(rel(findup('bar.txt', opts)), 'test/fixtures/a/b/bar.txt', 'should find files');
test.equal(rel(findup('a.txt', opts)), 'test/fixtures/a.txt', 'should find files');
test.equal(rel(findup('?.txt', opts)), 'test/fixtures/a.txt', 'should support glob patterns');
test.equal(rel(findup('*.txt', opts)), 'test/fixtures/a/b/bar.txt', 'should find the first thing that matches the glob pattern');
test.equal(rel(findup(['b*.txt', 'f*.txt'], opts)), 'test/fixtures/a/b/bar.txt', 'should find the first thing that matches any of the glob patterns');
test.equal(rel(findup(['f*.txt', 'b*.txt'], opts)), 'test/fixtures/a/b/bar.txt', 'should find the first thing that matches any of the glob patterns');
test.equal(rel(findup('foo.txt', opts)), path.normalize('test/fixtures/a/foo.txt'), 'should find files');
test.equal(rel(findup('bar.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find files');
test.equal(rel(findup('a.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should find files');
test.equal(rel(findup('?.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should support glob patterns');
test.equal(rel(findup('*.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches the glob pattern');
test.equal(rel(findup(['b*.txt', 'f*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns');
test.equal(rel(findup(['f*.txt', 'b*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns');
test.equal(findup('not-gonna-exist-i-hope.txt', opts), null, 'should returning null if no files found');
test.done();
},
'cwd': function(test) {
test.expect(8);
process.chdir('test/fixtures/a/b');
test.equal(rel(findup('foo.txt')), '../foo.txt', 'should find files');
test.equal(rel(findup('foo.txt')), path.normalize('../foo.txt'), 'should find files');
test.equal(rel(findup('bar.txt')), 'bar.txt', 'should find files');
test.equal(rel(findup('a.txt')), '../../a.txt', 'should find files');
test.equal(rel(findup('?.txt')), '../../a.txt', 'should support glob patterns');
test.equal(rel(findup('a.txt')), path.normalize('../../a.txt'), 'should find files');
test.equal(rel(findup('?.txt')), path.normalize('../../a.txt'), 'should support glob patterns');
test.equal(rel(findup('*.txt')), 'bar.txt', 'should find the first thing that matches the glob pattern');
test.equal(rel(findup(['b*.txt', 'f*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns');
test.equal(rel(findup(['f*.txt', 'b*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns');
Expand Down

0 comments on commit 0ea26fa

Please sign in to comment.