diff --git a/test/stats-uid-gid.js b/test/stats-uid-gid.js index 58ce661..11d6b84 100644 --- a/test/stats-uid-gid.js +++ b/test/stats-uid-gid.js @@ -14,9 +14,7 @@ fs.statSync = function(path) { var gfs = require('../graceful-fs.js') -test('graceful fs uses same stats constructor as fs', function (t) { - t.equal(gfs.Stats, fs.Stats, 'should reference the same constructor') - +test('graceful fs includes correct uid & gid', function (t) { if (!process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) { t.equal(fs.statSync(__filename).uid, -2) t.equal(fs.statSync(__filename).gid, -2) @@ -28,6 +26,16 @@ test('graceful fs uses same stats constructor as fs', function (t) { t.end() }) +;(process.platform !== 'win32') && test('graceful fs includes valid uid & gid (async)', function (t) { + gfs.stat(__filename, function (er, stats) { + t.notOk(er) + t.ok(stats) + t.ok(stats.uid) + t.ok(stats.gid) + t.end() + }) +}) + test('does not throw when async stat fails', function (t) { gfs.stat(__filename + ' this does not exist', function (er, stats) { t.ok(er) diff --git a/test/stats.js b/test/stats.js index 4519012..a7cbfea 100644 --- a/test/stats.js +++ b/test/stats.js @@ -5,8 +5,17 @@ var gfs = require('../graceful-fs.js') test('graceful fs uses same stats constructor as fs', function (t) { t.equal(gfs.Stats, fs.Stats, 'should reference the same constructor') t.ok(fs.statSync(__filename) instanceof fs.Stats, - 'should be instance of fs.Stats') + 'should be instance of fs.Stats (built-in fs.statSync call)') t.ok(gfs.statSync(__filename) instanceof fs.Stats, 'should be instance of fs.Stats') t.end() }) + +test('graceful fs uses same stats constructor as fs (async)', function (t) { + gfs.stat(__filename, function (er, stats) { + t.notOk(er, 'should not receive an error result') + t.ok(stats, 'should receive a valid stats object') + t.ok(stats instanceof fs.Stats, 'should receive a valid stats object') + t.end() + }) +})