From 8e7da604685a64da4224f87b071020a168e0c003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20Can=20Alt=C4=B1n?= Date: Sun, 18 Feb 2024 18:46:43 +0300 Subject: [PATCH] test: test surrogate pair filenames on windows PR-URL: https://github.com/nodejs/node/pull/51800 Fixes: https://github.com/nodejs/node/issues/51789 Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Yagiz Nizipli Reviewed-By: Marco Ippolito --- ...test-fs-operations-with-surrogate-pairs.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/parallel/test-fs-operations-with-surrogate-pairs.js diff --git a/test/parallel/test-fs-operations-with-surrogate-pairs.js b/test/parallel/test-fs-operations-with-surrogate-pairs.js new file mode 100644 index 00000000000000..d46623e8c208ae --- /dev/null +++ b/test/parallel/test-fs-operations-with-surrogate-pairs.js @@ -0,0 +1,31 @@ +'use strict'; + +require('../common'); +const fs = require('node:fs'); +const path = require('node:path'); +const assert = require('node:assert'); +const { describe, it } = require('node:test'); +const tmpdir = require('../common/tmpdir'); + +tmpdir.refresh(); + +describe('File operations with filenames containing surrogate pairs', () => { + it('should write, read, and delete a file with surrogate pairs in the filename', () => { + // Create a temporary directory + const tempdir = fs.mkdtempSync(tmpdir.resolve('emoji-fruit-🍇 🍈 🍉 🍊 🍋')); + assert.strictEqual(fs.existsSync(tempdir), true); + + const filename = '🚀🔥🛸.txt'; + const content = 'Test content'; + + // Write content to a file + fs.writeFileSync(path.join(tempdir, filename), content); + + // Read content from the file + const readContent = fs.readFileSync(path.join(tempdir, filename), 'utf8'); + + // Check if the content matches + assert.strictEqual(readContent, content); + + }); +});