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

Function runTests

test/parallel/test-fastutf8stream-flush.js:28–139  ·  view source on GitHub ↗
(sync)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 11

writeMethod · 0.95
flushMethod · 0.95
endMethod · 0.95
destroyMethod · 0.95
writeFileSyncFunction · 0.85
getTempFileFunction · 0.70
readFileFunction · 0.70
openSyncFunction · 0.70
joinFunction · 0.50
onMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…