mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. Backport-PR-URL: https://github.com/nodejs/node/pull/11795 PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
24 lines
559 B
JavaScript
24 lines
559 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const fn = path.join(common.tmpDir, 'write.txt');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
const foo = 'foo';
|
|
const fd = fs.openSync(fn, 'w');
|
|
|
|
let written = fs.writeSync(fd, '');
|
|
assert.strictEqual(0, written);
|
|
|
|
fs.writeSync(fd, foo);
|
|
|
|
const bar = 'bár';
|
|
written = fs.writeSync(fd, Buffer.from(bar), 0, Buffer.byteLength(bar));
|
|
assert.ok(written > 3);
|
|
fs.closeSync(fd);
|
|
|
|
assert.strictEqual(fs.readFileSync(fn, 'utf8'), 'foobár');
|