Skip to content

Commit

Permalink
Fix REPL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Aug 29, 2024
1 parent 485f76d commit 6699bd5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/repl/test/repl.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import util from 'node:util';
import { describe, expect, test } from 'vitest';
import { REPL } from '../src/repl';
import { REPL, type REPLOptions } from '../src/index';

const encoder = new TextEncoder();

class NodeREPL extends REPL {
const opts: REPLOptions = {
inspect(v: unknown): string {
return util.inspect(v);
}
escape(): void {}
}
},
};

describe('REPL', () => {
test('Renders empty prompt', async () => {
const stream = new TextDecoderStream();
const repl = new NodeREPL(stream.writable.getWriter());
const repl = new REPL(stream.writable.getWriter(), opts);
const reader = stream.readable.getReader();

repl.renderPrompt();
Expand All @@ -27,7 +26,7 @@ describe('REPL', () => {

test('Echoes user input', async () => {
const stream = new TextDecoderStream();
const repl = new NodeREPL(stream.writable.getWriter());
const repl = new REPL(stream.writable.getWriter(), opts);
const reader = stream.readable.getReader();

repl.write(encoder.encode('hello world'));
Expand All @@ -41,7 +40,7 @@ describe('REPL', () => {
describe('submit()', () => {
test('Evaluates user input', async () => {
const stream = new TextDecoderStream();
const repl = new NodeREPL(stream.writable.getWriter());
const repl = new REPL(stream.writable.getWriter(), opts);
const reader = stream.readable.getReader();

repl.write(encoder.encode('1 + 1'));
Expand Down

0 comments on commit 6699bd5

Please sign in to comment.