Skip to content

Commit caf033c

Browse files
committed
test: fix mocks, ignore type errors
1 parent 24f33c6 commit caf033c

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

packages/core/test/mock-readable.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import { ReadStream } from 'node:tty';
1+
import { Readable } from 'node:stream';
22

3-
export class MockReadable extends ReadStream {
3+
export class MockReadable extends Readable {
44
protected _buffer: unknown[] | null = [];
5-
fd = 0 as const;
6-
7-
constructor() {
8-
super(0);
9-
}
105

116
_read() {
127
if (this._buffer === null) {

packages/core/test/mock-writable.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import { WriteStream } from 'node:tty';
1+
import { Writable } from 'node:stream';
22

3-
export class MockWritable extends WriteStream {
3+
export class MockWritable extends Writable {
44
public buffer: string[] = [];
5-
fd = 1 as const;
6-
7-
constructor() {
8-
super(1);
9-
}
105

116
// biome-ignore lint/suspicious/noExplicitAny: any is the official type
127
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null | undefined) => void): void {

packages/core/test/prompts/prompt.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { describe, expect, test, afterEach, beforeEach, vi } from 'vitest';
2-
import { default as Prompt, isCancel } from '../../src/prompts/prompt.js';
31
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';
44
import { MockReadable } from '../mock-readable.js';
55
import { MockWritable } from '../mock-writable.js';
66

packages/core/test/utils.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('utils', () => {
1414
test('clears output on keypress', () => {
1515
const input = new MockReadable();
1616
const output = new MockWritable();
17+
// @ts-ignore
1718
const callback = block({ input, output });
1819

1920
const event: Key = {
@@ -28,6 +29,7 @@ describe('utils', () => {
2829
test('clears output vertically when return pressed', () => {
2930
const input = new MockReadable();
3031
const output = new MockWritable();
32+
// @ts-ignore
3133
const callback = block({ input, output });
3234

3335
const event: Key = {
@@ -42,6 +44,7 @@ describe('utils', () => {
4244
test('ignores additional keypresses after dispose', () => {
4345
const input = new MockReadable();
4446
const output = new MockWritable();
47+
// @ts-ignore
4548
const callback = block({ input, output });
4649

4750
const event: Key = {
@@ -58,9 +61,11 @@ describe('utils', () => {
5861
const input = new MockReadable();
5962
const output = new MockWritable();
6063
// purposely don't keep the callback since we would exit the process
64+
// @ts-ignore
6165
block({ input, output });
66+
// @ts-ignore
6267
const spy = vi.spyOn(process, 'exit').mockImplementation(() => {
63-
throw undefined;
68+
return
6469
});
6570

6671
const event: Key = {
@@ -75,6 +80,7 @@ describe('utils', () => {
7580
test('does not clear if overwrite=false', () => {
7681
const input = new MockReadable();
7782
const output = new MockWritable();
83+
// @ts-ignore
7884
const callback = block({ input, output, overwrite: false });
7985

8086
const event: Key = {

0 commit comments

Comments
 (0)