Skip to content

Commit

Permalink
test fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed May 31, 2024
1 parent d0d9ae3 commit c64607f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ module.exports = {
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/consistent-indexed-object-style': 'warn',
'@typescript-eslint/no-confusing-void-expression': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
'@typescript-eslint/await-thenable': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,34 @@ describe('useConfirmCrashRecovery', () => {
fireEvent.click(screen.getByRole('button', { name: 'Start over' }))
// the confirmation should now not be null
expect(result.current[1]).not.toBeNull()
})

it('renders the modal with the right props when you click back', () => {
const { result } = renderHook(
() =>
useConfirmCrashRecovery({
...mockProps,
sendCommands: mockSendCommands,
}),
{
wrapper: ({ children }) => (
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
),
}
)

// the explicitly rerender to incorporate newly non-null confirmation
renderWithProviders(<div>{result.current[1] ?? result.current[0]}</div>, {
i18nInstance: i18n,
})
const [{ rerender }] = renderWithProviders(
<div>{result.current[1] ?? result.current[0]}</div>,
{
i18nInstance: i18n,
}
)

// click the link to launch the modal
fireEvent.click(screen.getByRole('button', { name: 'Start over' }))

rerender(<div>{result.current[1] ?? result.current[0]}</div>)

// click the "back" link in the confirmation
const closeConfirmationButton = screen.getByRole('button', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('IncompatibleModuleTakeover', () => {
;['desktop', 'odd'].forEach(target => {
it(`should render nothing on ${target} when no incompatible modules are attached`, () => {
getRenderer([])({ ...props, isOnDevice: target === 'odd' })
expect(screen.getByTestId(TOP_PORTAL_ID)).resolves.toBeEmptyDOMElement()
expect(screen.getByTestId(MODAL_PORTAL_ID)).resolves.toBeEmptyDOMElement()
expect(screen.queryByTestId(TOP_PORTAL_ID)).toBeEmptyDOMElement()
expect(screen.queryByTestId(MODAL_PORTAL_ID)).toBeEmptyDOMElement()
expect(screen.queryByText(/TEST ELEMENT/)).toBeNull()
})
})
Expand Down

0 comments on commit c64607f

Please sign in to comment.