MCPcopy Index your code
hub / github.com/nodejs/node / runTests

Function runTests

test/parallel/test-fastutf8stream-write.js:31–205  ·  view source on GitHub ↗
(sync)

Source from the content-addressed store, hash-verified

29runTests(true);
30
31function runTests(sync) {
32 {
33 const dest = getTempFile();
34 const fd = openSync(dest, 'w');
35 const stream = new Utf8Stream({ fd, sync });
36 stream.on('ready', common.mustCall(() => {
37 assert.ok(stream.write('hello world\n'));
38 assert.ok(stream.write('something else\n'));
39
40 stream.end();
41
42 stream.on('finish', common.mustCall(() => {
43 readFile(dest, 'utf8', common.mustSucceed((data) => {
44 assert.strictEqual(data, 'hello world\nsomething else\n');
45 }));
46 }));
47 }));
48 }
49
50 {
51 const dest = getTempFile();
52 const fd = openSync(dest, 'w');
53 const stream = new Utf8Stream({ fd, sync });
54
55 stream.once('drain', common.mustCall(() => {
56 readFile(dest, 'utf8', common.mustSucceed((data) => {
57 assert.strictEqual(data, 'hello world\n');
58 assert.ok(stream.write('something else\n'));
59
60 stream.once('drain', common.mustCall(() => {
61 readFile(dest, 'utf8', common.mustSucceed((data) => {
62 assert.strictEqual(data, 'hello world\nsomething else\n');
63 stream.end();
64 }));
65 }));
66 }));
67 }));
68
69 assert.ok(stream.write('hello world\n'));
70 };
71
72 {
73 const dest = getTempFile();
74 const fd = openSync(dest, 'w');
75 const stream = new Utf8Stream({ fd, sync });
76 const source = createReadStream(__filename, { encoding: 'utf8' });
77
78 source.pipe(stream);
79
80 stream.on('finish', common.mustCall(() => {
81 readFile(__filename, 'utf8', common.mustSucceed((expected) => {
82 readFile(dest, 'utf8', common.mustSucceed((data) => {
83 assert.strictEqual(data, expected);
84 }));
85 }));
86 }));
87 }
88

Callers 1

Calls 12

writeMethod · 0.95
endMethod · 0.95
getTempFileFunction · 0.70
openSyncFunction · 0.70
readFileFunction · 0.70
writeSyncFunction · 0.70
writeFunction · 0.70
createReadStreamFunction · 0.50
setTimeoutFunction · 0.50
onMethod · 0.45
okMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…