Skip to content

Commit

Permalink
Fix test for OnboardingSuccess component
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Sep 23, 2024
1 parent d23b53f commit 2b37691
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/components/Views/OnboardingSuccess/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import OnboardingSuccess from './';
import renderWithProvider from '../../../util/test/renderWithProvider';
import { useSelector } from 'react-redux';
import { selectProviderConfig } from '../../../selectors/networkController';
import Button from '../../../component-library/components/Buttons/Button/Button';

Check failure on line 9 in app/components/Views/OnboardingSuccess/index.test.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

'Button' is defined but never used

// Define ProviderConfig type
interface ProviderConfig {
Expand Down Expand Up @@ -40,13 +41,25 @@ const mockProviderConfig: ProviderConfig = {
};

describe('OnboardingSuccess', () => {
it('should render correctly', () => {
it('should render correctly and handle onDone', () => {
(useSelector as jest.Mock).mockImplementation((selector: typeof selectProviderConfig) => {
if (selector === selectProviderConfig) return mockProviderConfig;
});
const { toJSON } = renderWithProvider(
<OnboardingSuccess onDone={jest.fn()} backedUpSRP={false} noSRP={false} />,
const mockOnDone = jest.fn();
const { getByTestId, toJSON } = renderWithProvider(
<OnboardingSuccess onDone={mockOnDone} backedUpSRP={false} noSRP={false} />,
);

// Snapshot test
expect(toJSON()).toMatchSnapshot();

const doneButton = getByTestId('onboarding-success-done-button');
expect(doneButton).toBeTruthy();

// Simulate button press
doneButton.props.onPress();

// Check if mockOnDone was called
expect(mockOnDone).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 2b37691

Please sign in to comment.