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: #51800
Fixes: #51789
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
  • Loading branch information
mertcanaltin authored and richardlau committed Feb 28, 2024
1 parent 8a94177 commit 8e7da60
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 8e7da60

Please sign in to comment.