diff --git a/tests/node_compat/config.jsonc b/tests/node_compat/config.jsonc index d163765daa..5acbd25dc3 100644 --- a/tests/node_compat/config.jsonc +++ b/tests/node_compat/config.jsonc @@ -338,6 +338,7 @@ "test-fs-open-numeric-flags.js", "test-fs-open.js", "test-fs-opendir.js", + "test-fs-promises-file-handle-stat.js", "test-fs-promises-writefile-with-fd.js", "test-fs-read-stream-autoClose.js", "test-fs-read-stream-concurrent-reads.js", diff --git a/tests/node_compat/runner/TODO.md b/tests/node_compat/runner/TODO.md index ef1f36840a..acd5ec45c4 100644 --- a/tests/node_compat/runner/TODO.md +++ b/tests/node_compat/runner/TODO.md @@ -822,7 +822,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co - [parallel/test-fs-promises-file-handle-read-worker.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-read-worker.js) - [parallel/test-fs-promises-file-handle-read.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-read.js) - [parallel/test-fs-promises-file-handle-readFile.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-readFile.js) -- [parallel/test-fs-promises-file-handle-stat.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-stat.js) - [parallel/test-fs-promises-file-handle-stream.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-stream.js) - [parallel/test-fs-promises-file-handle-sync.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-sync.js) - [parallel/test-fs-promises-file-handle-truncate.js](https://github.com/nodejs/node/tree/v20.11.1/test/parallel/test-fs-promises-file-handle-truncate.js) diff --git a/tests/node_compat/test/parallel/test-fs-promises-file-handle-stat.js b/tests/node_compat/test/parallel/test-fs-promises-file-handle-stat.js new file mode 100644 index 0000000000..45315c10b2 --- /dev/null +++ b/tests/node_compat/test/parallel/test-fs-promises-file-handle-stat.js @@ -0,0 +1,30 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file + +// Copyright Joyent and Node contributors. All rights reserved. MIT license. +// Taken from Node 20.11.1 +// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. + +'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());