node/test/parallel/test-fs-readdir-ucs2.js
Santiago Gimeno dee0e3a333 test: use common platform helpers everywhere
Use the common.isWindows, common.isFreeBSD and common.isSunOS where
possible.
Add common.isOSX and common.isLinux.
Fix `test-fs-read-file-sync-hostname` as in its current form was not
being run anywhere.

PR-URL: https://github.com/nodejs/node/pull/7845
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-07-27 08:25:26 +02:00

32 lines
765 B
JavaScript

'use strict';
const common = require('../common');
const path = require('path');
const fs = require('fs');
const assert = require('assert');
if (!common.isLinux) {
common.skip('Test is linux specific.');
return;
}
common.refreshTmpDir();
const filename = '\uD83D\uDC04';
const root = Buffer.from(`${common.tmpDir}${path.sep}`);
const filebuff = Buffer.from(filename, 'ucs2');
const fullpath = Buffer.concat([root, filebuff]);
fs.closeSync(fs.openSync(fullpath, 'w+'));
fs.readdir(common.tmpDir, 'ucs2', (err, list) => {
if (err) throw err;
assert.equal(1, list.length);
const fn = list[0];
assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2'));
assert.strictEqual(fn, filename);
});
process.on('exit', () => {
fs.unlinkSync(fullpath);
});