node/test/parallel/test-fs-promises-file-handle-stat.js
Livia Medeiros 74e0ca3f49
test: use tmpdir.resolve() in fs tests
PR-URL: https://github.com/nodejs/node/pull/49125
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-08-15 13:45:14 +00:00

24 lines
585 B
JavaScript

'use strict';
const common = require('../common');
// The following tests validate base functionality for the fs.promises
// FileHandle.stat method.
const { open } = require('fs').promises;
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
tmpdir.refresh();
async function validateStat() {
const filePath = tmpdir.resolve('tmp-read-file.txt');
const fileHandle = await open(filePath, 'w+');
const stats = await fileHandle.stat();
assert.ok(stats.mtime instanceof Date);
await fileHandle.close();
}
validateStat()
.then(common.mustCall());