Skip to content

Commit

Permalink
added test for ErrorBoundary component. natcap#1119
Browse files Browse the repository at this point in the history
  • Loading branch information
davemfish committed Dec 2, 2022
1 parent a912222 commit 3645fd1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions workbench/src/renderer/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export default class App extends React.Component {
}

render() {
throw new Error('help')
const {
investList,
investSettings,
Expand Down
1 change: 0 additions & 1 deletion workbench/src/renderer/components/HomeTab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class RecentInvestJobs extends React.Component {
}

render() {
throw new Error('help')
// Buttons to load each recently saved state
const recentButtons = [];
const { recentJobs } = this.props;
Expand Down
21 changes: 21 additions & 0 deletions workbench/tests/renderer/errorboundary.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';

import ErrorBoundary from '../../src/renderer/components/ErrorBoundary';

function MyComponent() {
throw new Error('From MyComponent');
}

test('Error Boundary: displays useful content', async () => {
const { getByRole, getByText } = render(
<ErrorBoundary>
<MyComponent />
</ErrorBoundary>
);

expect(getByText('Something went wrong.')).toBeInTheDocument();
expect(getByRole('button', { name: 'Find My Logs' })).toBeInTheDocument();
expect(getByRole('link')).toHaveTextContent('community.naturalcapitalproject.org');
});

0 comments on commit 3645fd1

Please sign in to comment.