From 40247ca2a94ceeccc4c221130637b97ebb2a7100 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Wed, 6 Dec 2023 15:55:26 -0500 Subject: [PATCH] user more semantic names --- test/Wizard.test.ts | 8 ++++---- test/services/MockTerminal.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/Wizard.test.ts b/test/Wizard.test.ts index 0e0ad49..79672ff 100644 --- a/test/Wizard.test.ts +++ b/test/Wizard.test.ts @@ -34,10 +34,10 @@ describe("Wizard", () => { }) const args = ReadonlyArray.make("--wizard") const cliFiber = yield* _(Effect.fork(cli(args))) - yield* _(MockTerminal.enterText("Hello, World!")) - yield* _(MockTerminal.enterKey("enter")) - yield* _(MockTerminal.enterKey("0")) - yield* _(MockTerminal.enterKey("enter")) + yield* _(MockTerminal.inputText("Hello, World!")) + yield* _(MockTerminal.inputKey("enter")) + yield* _(MockTerminal.inputKey("0")) + yield* _(MockTerminal.inputKey("enter")) yield* _(Fiber.join(cliFiber)) const result = yield* _(MockConsole.getLines()) console.log({ result }) diff --git a/test/services/MockTerminal.ts b/test/services/MockTerminal.ts index aa40cc7..cfeec6a 100644 --- a/test/services/MockTerminal.ts +++ b/test/services/MockTerminal.ts @@ -12,8 +12,8 @@ import * as ReadonlyArray from "effect/ReadonlyArray" // ============================================================================= export interface MockTerminal extends Terminal.Terminal { - readonly enterText: (text: string) => Effect.Effect - readonly enterKey: ( + readonly inputText: (text: string) => Effect.Effect + readonly inputKey: ( key: string, modifiers?: Partial ) => Effect.Effect @@ -45,12 +45,12 @@ export const make = Effect.gen(function*(_) { Queue.shutdown )) - const enterText: MockTerminal["enterText"] = (text: string) => { + const inputText: MockTerminal["inputText"] = (text: string) => { const inputs = ReadonlyArray.map(text.split(""), (key) => toUserInput(key)) return Queue.offerAll(queue, inputs).pipe(Effect.asUnit) } - const enterKey: MockTerminal["enterKey"] = ( + const inputKey: MockTerminal["inputKey"] = ( key: string, modifiers?: Partial ) => { @@ -73,8 +73,8 @@ export const make = Effect.gen(function*(_) { display, readInput, readLine: Effect.succeed(""), - enterKey, - enterText + inputKey, + inputText }) }) @@ -89,7 +89,7 @@ export const layer = Layer.scoped(MockTerminal, make) // ============================================================================= export const { columns, readInput, readLine } = Effect.serviceConstants(MockTerminal) -export const { enterKey, enterText } = Effect.serviceFunctions(MockTerminal) +export const { inputKey, inputText } = Effect.serviceFunctions(MockTerminal) // ============================================================================= // Utilities