2014-05-23 20:53:50 +00:00
|
|
|
var Filer = require('../..');
|
|
|
|
var util = require('../lib/test-utils.js');
|
|
|
|
var expect = require('chai').expect;
|
2014-01-21 21:25:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
describe('trailing slashes in path names, issue 105', function() {
|
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-01-21 21:25:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
it('should deal with trailing slashes properly, path == path/', function(done) {
|
|
|
|
var fs = util.fs();
|
2014-01-21 21:25:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
fs.mkdir('/tmp', function(err) {
|
|
|
|
if(err) throw err;
|
|
|
|
|
|
|
|
fs.mkdir('/tmp/foo', function(err) {
|
2014-01-21 21:25:09 +00:00
|
|
|
if(err) throw err;
|
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
// Without trailing slash
|
|
|
|
fs.readdir('/tmp', function(err, result1) {
|
2014-01-21 21:25:09 +00:00
|
|
|
if(err) throw err;
|
2014-05-23 20:53:50 +00:00
|
|
|
expect(result1).to.exist;
|
|
|
|
expect(result1.length).to.equal(1);
|
2014-01-21 21:25:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
// With trailing slash
|
|
|
|
fs.readdir('/tmp/', function(err, result2) {
|
2014-01-21 21:25:09 +00:00
|
|
|
if(err) throw err;
|
2014-05-23 20:53:50 +00:00
|
|
|
expect(result2).to.exist;
|
|
|
|
expect(result2[0]).to.equal('foo');
|
|
|
|
expect(result1).to.deep.equal(result2);
|
|
|
|
done();
|
2014-01-21 21:25:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|