Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickwesselman committed Aug 28, 2024
1 parent 67ebdb4 commit 7d11de2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Props = {
readonly writeToStderr: (data: string) => void;
readonly exitOnCtrlC: boolean;
readonly onExit: (error?: Error) => void;
readonly debug: boolean;
};

type State = {
Expand Down Expand Up @@ -127,11 +128,15 @@ export default class App extends PureComponent<Props, State> {
}

override componentDidMount() {
cliCursor.hide(this.props.stdout);
if (!this.props.debug) {
cliCursor.hide(this.props.stdout);
}
}

override componentWillUnmount() {
cliCursor.show(this.props.stdout);
if (!this.props.debug) {
cliCursor.show(this.props.stdout);
}

// ignore calling setRawMode on an handle stdin it cannot be called
if (this.isRawModeSupported()) {
Expand Down
1 change: 1 addition & 0 deletions src/ink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export default class Ink {
writeToStdout={this.writeToStdout}
writeToStderr={this.writeToStderr}
exitOnCtrlC={this.options.exitOnCtrlC}
debug={this.options.debug}
onExit={this.unmount}
>
{node}
Expand Down
7 changes: 5 additions & 2 deletions test/errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ test('catch and display error', t => {
throw new Error('Oh no');
};

render(<Test />, {stdout});
render(<Test />, {
stdout,
debug: true,
});

t.deepEqual(
stripAnsi((stdout.write as any).lastCall.args[0] as string)
Expand All @@ -40,7 +43,7 @@ test('catch and display error', t => {
" 22: throw new Error('Oh no');",
' 23: };',
' 24:',
' 25: render(<Test />, {stdout});',
' 25: render(<Test />, {',
'',
' - Test (test/errors.tsx:22:9)',
],
Expand Down
1 change: 1 addition & 0 deletions test/helpers/create-stdout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const createStdout = (columns?: number): FakeStdout => {

const write = spy();
stdout.write = write;
stdout.isTTY = true;

stdout.get = () => write.lastCall.args[0] as string;

Expand Down

0 comments on commit 7d11de2

Please sign in to comment.