mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
* Align `process.nextTick` execution order with Node * some tests * formatting * fixups * fix the test failures * simplify the logic here * push it up --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: dave caruso <me@paperdave.net>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import readlinePromises from "node:readline/promises";
|
|
import { EventEmitter } from "node:events";
|
|
import { createTest } from "node-harness";
|
|
const { describe, it, expect, createDoneDotAll, createCallCheckCtx, assert } = createTest(import.meta.path);
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Helpers
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class FakeInput extends EventEmitter {
|
|
output = "";
|
|
resume() {}
|
|
pause() {}
|
|
write(data: any) {
|
|
this.output += data;
|
|
}
|
|
end() {}
|
|
reset() {
|
|
this.output = "";
|
|
}
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Tests
|
|
// ----------------------------------------------------------------------------
|
|
|
|
describe("readline/promises.createInterface()", () => {
|
|
it("should throw an error when failed completion", done => {
|
|
const createDone = createDoneDotAll(done);
|
|
const { mustCall, mustNotCall } = createCallCheckCtx(createDone());
|
|
|
|
const fi = new FakeInput();
|
|
// @ts-ignore
|
|
const rli = new readlinePromises.Interface({
|
|
input: fi,
|
|
output: fi,
|
|
terminal: true,
|
|
completer: mustCall(() => Promise.reject(new Error("message"))),
|
|
});
|
|
|
|
rli.on("line", mustNotCall());
|
|
fi.emit("data", "\t");
|
|
queueMicrotask(() => {
|
|
expect(fi.output).toMatch(/^Tab completion error/);
|
|
rli.close();
|
|
done();
|
|
});
|
|
});
|
|
});
|