[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

test: fix mocks, ignore type errors

Nate Moore (Nov 21, 2024, 9:15 PM -0600) caf033c2 24f33c64

+13 -17
+2 -7
packages/core/test/mock-readable.ts
··· 1 - import { ReadStream } from 'node:tty'; 1 + import { Readable } from 'node:stream'; 2 2 3 - export class MockReadable extends ReadStream { 3 + export class MockReadable extends Readable { 4 4 protected _buffer: unknown[] | null = []; 5 - fd = 0 as const; 6 - 7 - constructor() { 8 - super(0); 9 - } 10 5 11 6 _read() { 12 7 if (this._buffer === null) {
+2 -7
packages/core/test/mock-writable.ts
··· 1 - import { WriteStream } from 'node:tty'; 1 + import { Writable } from 'node:stream'; 2 2 3 - export class MockWritable extends WriteStream { 3 + export class MockWritable extends Writable { 4 4 public buffer: string[] = []; 5 - fd = 1 as const; 6 - 7 - constructor() { 8 - super(1); 9 - } 10 5 11 6 // biome-ignore lint/suspicious/noExplicitAny: any is the official type 12 7 _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null | undefined) => void): void {
+2 -2
packages/core/test/prompts/prompt.test.ts
··· 1 - import { describe, expect, test, afterEach, beforeEach, vi } from 'vitest'; 2 - import { default as Prompt, isCancel } from '../../src/prompts/prompt.js'; 3 1 import { cursor } from 'sisteransi'; 2 + import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; 3 + import { default as Prompt, isCancel } from '../../src/prompts/prompt.js'; 4 4 import { MockReadable } from '../mock-readable.js'; 5 5 import { MockWritable } from '../mock-writable.js'; 6 6
+7 -1
packages/core/test/utils.test.ts
··· 14 14 test('clears output on keypress', () => { 15 15 const input = new MockReadable(); 16 16 const output = new MockWritable(); 17 + // @ts-ignore 17 18 const callback = block({ input, output }); 18 19 19 20 const event: Key = { ··· 28 29 test('clears output vertically when return pressed', () => { 29 30 const input = new MockReadable(); 30 31 const output = new MockWritable(); 32 + // @ts-ignore 31 33 const callback = block({ input, output }); 32 34 33 35 const event: Key = { ··· 42 44 test('ignores additional keypresses after dispose', () => { 43 45 const input = new MockReadable(); 44 46 const output = new MockWritable(); 47 + // @ts-ignore 45 48 const callback = block({ input, output }); 46 49 47 50 const event: Key = { ··· 58 61 const input = new MockReadable(); 59 62 const output = new MockWritable(); 60 63 // purposely don't keep the callback since we would exit the process 64 + // @ts-ignore 61 65 block({ input, output }); 66 + // @ts-ignore 62 67 const spy = vi.spyOn(process, 'exit').mockImplementation(() => { 63 - throw undefined; 68 + return 64 69 }); 65 70 66 71 const event: Key = { ··· 75 80 test('does not clear if overwrite=false', () => { 76 81 const input = new MockReadable(); 77 82 const output = new MockWritable(); 83 + // @ts-ignore 78 84 const callback = block({ input, output, overwrite: false }); 79 85 80 86 const event: Key = {