From 7483a4d30a1fcc9f7fd0f859ed0b6a782af823dd Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Sat, 8 May 2021 12:45:50 +1000 Subject: [PATCH] test: nodejs v6 has no atimeMs in fs.stat --- test/lib/fs.lstat.spec.js | 14 +++++++------- test/lib/fs.stat-fstat.spec.js | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/lib/fs.lstat.spec.js b/test/lib/fs.lstat.spec.js index 6b1fdcf..f0442a1 100644 --- a/test/lib/fs.lstat.spec.js +++ b/test/lib/fs.lstat.spec.js @@ -30,7 +30,7 @@ describe('fs.lstat(path, callback)', function() { } assert.isTrue(stats.isSymbolicLink()); assert.isFalse(stats.isFile()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); done(); }); }); @@ -54,7 +54,7 @@ describe('fs.lstat(path, callback)', function() { } assert.isTrue(stats.isSymbolicLink()); assert.isFalse(stats.isFile()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); done(); }); }); @@ -75,7 +75,7 @@ describe('fs.lstat(path, callback)', function() { fs.promises.lstat('link').then(function(stats) { assert.isTrue(stats.isSymbolicLink()); assert.isFalse(stats.isFile()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); done(); }, done); }); @@ -99,7 +99,7 @@ describe('fs.lstat(path, callback)', function() { } assert.isTrue(stats.isFile()); assert.isFalse(stats.isSymbolicLink()); - assert.equal(stats.mtimeMs, 1); + assert.equal(stats.mtime.getTime(), 1); done(); }); }); @@ -120,7 +120,7 @@ describe('fs.lstat(path, callback)', function() { fs.promises.lstat('file.txt').then(function(stats) { assert.isTrue(stats.isFile()); assert.isFalse(stats.isSymbolicLink()); - assert.equal(stats.mtimeMs, 1); + assert.equal(stats.mtime.getTime(), 1); done(); }, done); }); @@ -177,7 +177,7 @@ describe('fs.lstatSync(path)', function() { const stats = fs.lstatSync('link'); assert.isTrue(stats.isSymbolicLink()); assert.isFalse(stats.isFile()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); }); inVersion('>=10.5.0').it('stats a symbolic link with bigint', function() { @@ -191,7 +191,7 @@ describe('fs.lstatSync(path)', function() { const stats = fs.lstatSync('file.txt'); assert.isTrue(stats.isFile()); assert.isFalse(stats.isSymbolicLink()); - assert.equal(stats.mtimeMs, 1); + assert.equal(stats.mtime.getTime(), 1); }); inVersion('>=10.5.0').it('stats a regular file with bigint', function() { diff --git a/test/lib/fs.stat-fstat.spec.js b/test/lib/fs.stat-fstat.spec.js index a166aa6..82b42d8 100644 --- a/test/lib/fs.stat-fstat.spec.js +++ b/test/lib/fs.stat-fstat.spec.js @@ -52,7 +52,7 @@ describe('fs.stat(path, callback)', function() { } assert.isTrue(stats.isFile()); assert.isFalse(stats.isDirectory()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); done(); }); }); @@ -76,7 +76,7 @@ describe('fs.stat(path, callback)', function() { } assert.isTrue(stats.isFile()); assert.isFalse(stats.isDirectory()); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); done(); }); }); @@ -101,7 +101,7 @@ describe('fs.stat(path, callback)', function() { assert.isTrue(stats.isFile()); assert.isFalse(stats.isDirectory()); done(); - assert.equal(stats.mtimeMs, 2); + assert.equal(stats.mtime.getTime(), 2); }, done); }); @@ -166,9 +166,9 @@ describe('fs.stat(path, callback)', function() { if (err) { return done(err); } - assert.equal(stats.ctimeMs, 1); - assert.equal(stats.mtimeMs, 2); - assert.equal(stats.atimeMs, 3); + assert.equal(stats.ctime.getTime(), 1); + assert.equal(stats.mtime.getTime(), 2); + assert.equal(stats.atime.getTime(), 3); assert.equal(stats.uid, 42); assert.equal(stats.gid, 43); assert.equal(stats.nlink, 1); @@ -195,9 +195,9 @@ describe('fs.stat(path, callback)', function() { withPromise.it('promise provides file stats', function(done) { fs.promises.stat('/path/to/file.txt').then(function(stats) { - assert.equal(stats.ctimeMs, 1); - assert.equal(stats.mtimeMs, 2); - assert.equal(stats.atimeMs, 3); + assert.equal(stats.ctime.getTime(), 1); + assert.equal(stats.mtime.getTime(), 2); + assert.equal(stats.atime.getTime(), 3); assert.equal(stats.uid, 42); assert.equal(stats.gid, 43); assert.equal(stats.nlink, 1);