Skip to content

Commit

Permalink
test: test surrogate pair filenames on windows
Browse files Browse the repository at this point in the history
PR-URL: nodejs#51800
Fixes: nodejs#51789
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
  • Loading branch information
mertcanaltin authored and richardlau committed Mar 1, 2024
1 parent 2a7047d commit 1a6b719
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-fs-operations-with-surrogate-pairs.js
Original file line number Diff line number Diff line change
@@ -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);

});
});

0 comments on commit 1a6b719

Please sign in to comment.