diff options
Diffstat (limited to 'tests/js/hero.mjs')
-rw-r--r-- | tests/js/hero.mjs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index 1debdc5..d4c6b57 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -33,6 +33,7 @@ import { rmIf, mkfifo, makeLineEmitter, + makePipeReaderFn, buildRoutes, promisifyServer, buildServer, @@ -1369,6 +1370,24 @@ const test_makeLineEmitter = async t => { }); }; +const test_makePipeReaderFn = async t => { + t.start("makePipeReaderFn()"); + + await t.test("we can close it manually with no data", async () => { + const path = "tests/hero-2.pipe"; + const lines = []; + const lineFn = x => lines.push(x); + const makePipeReader = makePipeReaderFn({ lineFn: null }); + }); + + await t.test("closing on pipe EOF reopens", async () => { + const path = "tests/hero-3.pipe"; + const lines = []; + const lineFn = x => lines.push(x); + const makePipeReader = makePipeReaderFn({ lineFn }); + }); +}; + const test_buildRoutes = async t => { t.start("buildRoutes()"); @@ -1604,6 +1623,7 @@ await runner.runTests([ test_rmIf, test_mkfifo, test_makeLineEmitter, + test_makePipeReaderFn, test_promisifyServer, test_buildServer, ]); |