Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
user more semantic names
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Dec 6, 2023
1 parent a63487c commit 40247ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions test/Wizard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
14 changes: 7 additions & 7 deletions test/services/MockTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import * as ReadonlyArray from "effect/ReadonlyArray"
// =============================================================================

export interface MockTerminal extends Terminal.Terminal {
readonly enterText: (text: string) => Effect.Effect<never, never, void>
readonly enterKey: (
readonly inputText: (text: string) => Effect.Effect<never, never, void>
readonly inputKey: (
key: string,
modifiers?: Partial<MockTerminal.Modifiers>
) => Effect.Effect<never, never, void>
Expand Down Expand Up @@ -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<MockTerminal.Modifiers>
) => {
Expand All @@ -73,8 +73,8 @@ export const make = Effect.gen(function*(_) {
display,
readInput,
readLine: Effect.succeed(""),
enterKey,
enterText
inputKey,
inputText
})
})

Expand All @@ -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
Expand Down

0 comments on commit 40247ca

Please sign in to comment.