diff --git a/src/components/App.test.tsx b/src/components/App.test.tsx
index d85e3af1..6876435f 100644
--- a/src/components/App.test.tsx
+++ b/src/components/App.test.tsx
@@ -18,9 +18,7 @@ describe('', () => {
})
it('should display Onboarding screen initially', async () => {
- act(() => {
- render()
- })
+ await act(async () => render())
// Onboarding screen
expect(screen.getByText('onboarding.splashscreen_button_get_started')).toBeInTheDocument()
@@ -29,20 +27,16 @@ describe('', () => {
// Wallets screen shown after Intro is skipped
expect(screen.queryByText('wallets.title')).not.toBeInTheDocument()
- await act(async () => {
- const skipIntro = screen.getByText('onboarding.splashscreen_button_skip_intro')
- await user.click(skipIntro)
- })
+ const skipIntro = screen.getByText('onboarding.splashscreen_button_skip_intro')
+ await user.click(skipIntro)
expect(screen.getByText('wallets.title')).toBeInTheDocument()
})
- it('should display Wallets screen directly when Onboarding screen has been shown', () => {
+ it('should display Wallets screen directly when Onboarding screen has been shown', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })
- act(() => {
- render()
- })
+ await act(async () => render())
// Wallets screen
expect(screen.getByText('wallets.title')).toBeInTheDocument()
@@ -52,17 +46,13 @@ describe('', () => {
it('should display a modal with beta warning information', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })
- act(() => {
- render()
- })
+ await act(async () => render())
expect(screen.getByText('Read this before using.')).toBeInTheDocument()
expect(screen.queryByText(/While JoinMarket is tried and tested, Jam is not./)).not.toBeInTheDocument()
- await act(async () => {
- const readThis = screen.getByText('Read this before using.')
- await user.click(readThis)
- })
+ const readThis = screen.getByText('Read this before using.')
+ await user.click(readThis)
expect(screen.getByText('footer.warning_alert_text')).toBeInTheDocument()
expect(screen.getByText('footer.warning_alert_button_ok')).toBeInTheDocument()
@@ -71,7 +61,7 @@ describe('', () => {
/*it('should display a websocket connection indicator', async () => {
global.__DEV__.addToAppSettings({ showOnboarding: false })
- act(() => {
+ await act(async () => {
render()
})
diff --git a/src/components/Balance.test.tsx b/src/components/Balance.test.tsx
index 92a5c9f5..7672cad6 100644
--- a/src/components/Balance.test.tsx
+++ b/src/components/Balance.test.tsx
@@ -1,4 +1,4 @@
-import { render, act } from '@testing-library/react'
+import { render } from '@testing-library/react'
import user from '@testing-library/user-event'
import { screen } from '../testUtils'
import { BTC, SATS } from '../utils'
@@ -112,16 +112,12 @@ describe('', () => {
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByText(`*****`))
- })
+ await user.click(screen.getByText(`*****`))
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByTestId(`sats-amount`))
- })
+ await user.click(screen.getByTestId(`sats-amount`))
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
@@ -132,9 +128,7 @@ describe('', () => {
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByText(`*****`))
- })
+ await user.click(screen.getByText(`*****`))
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
@@ -145,9 +139,7 @@ describe('', () => {
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByTestId(`sats-amount`))
- })
+ await user.click(screen.getByTestId(`sats-amount`))
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
@@ -158,16 +150,12 @@ describe('', () => {
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByTestId(`sats-amount`))
- })
+ await user.click(screen.getByTestId(`sats-amount`))
expect(screen.queryByTestId(`sats-amount`)).not.toBeInTheDocument()
expect(screen.getByText(`*****`)).toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByText(`*****`))
- })
+ await user.click(screen.getByText(`*****`))
expect(screen.getByTestId(`sats-amount`)).toBeInTheDocument()
expect(screen.queryByText(`*****`)).not.toBeInTheDocument()
diff --git a/src/components/CreateWallet.test.tsx b/src/components/CreateWallet.test.tsx
index 2677edaa..967d6888 100644
--- a/src/components/CreateWallet.test.tsx
+++ b/src/components/CreateWallet.test.tsx
@@ -59,7 +59,7 @@ describe('', () => {
})
it('should render without errors', () => {
- act(() => setup({}))
+ setup({})
expect(screen.getByText('create_wallet.title')).toBeVisible()
expect(screen.getByLabelText('create_wallet.label_wallet_name')).toBeVisible()
@@ -72,17 +72,15 @@ describe('', () => {
})
it('should show validation messages to user if form is invalid', async () => {
- act(() => setup({}))
+ setup({})
expect(await screen.queryByText('create_wallet.feedback_invalid_wallet_name')).not.toBeInTheDocument()
expect(await screen.queryByText('create_wallet.feedback_invalid_password')).not.toBeInTheDocument()
expect(await screen.queryByText('create_wallet.feedback_invalid_password_confirm')).not.toBeInTheDocument()
expect(await screen.findByText('create_wallet.button_create')).toBeVisible()
- await act(async () => {
- // click on the "create" button without filling the form
- await user.click(screen.getByText('create_wallet.button_create'))
- })
+ // click on the "create" button without filling the form
+ await user.click(screen.getByText('create_wallet.button_create'))
expect(await screen.findByText('create_wallet.feedback_invalid_wallet_name')).toBeVisible()
expect(await screen.findByText('create_wallet.feedback_invalid_password')).toBeVisible()
@@ -90,18 +88,16 @@ describe('', () => {
})
it('should not submit form if wallet name contains invalid characters', async () => {
- act(() => setup({}))
+ setup({})
expect(await screen.queryByText('create_wallet.feedback_invalid_wallet_name')).not.toBeInTheDocument()
expect(await screen.queryByText('create_wallet.feedback_invalid_password_confirm')).not.toBeInTheDocument()
- await act(async () => {
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), invalidTestWalletName)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- })
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), invalidTestWalletName)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- await act(async () => await user.click(screen.getByText('create_wallet.button_create')))
+ await user.click(screen.getByText('create_wallet.button_create'))
expect(await screen.findByText('create_wallet.button_create')).toBeVisible()
expect(await screen.findByText('create_wallet.feedback_invalid_wallet_name')).toBeVisible()
@@ -109,7 +105,7 @@ describe('', () => {
})
it('should not submit form if passwords do not match', async () => {
- act(() => setup({}))
+ setup({})
expect(await screen.findByPlaceholderText('create_wallet.placeholder_password')).toBeVisible()
expect(await screen.findByPlaceholderText('create_wallet.placeholder_password_confirm')).toBeVisible()
@@ -117,13 +113,11 @@ describe('', () => {
expect(await screen.queryByText('create_wallet.feedback_invalid_password_confirm')).not.toBeInTheDocument()
expect(await screen.findByText('create_wallet.button_create')).toBeVisible()
- await act(async () => {
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), '.*')
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), 'a_mismatching_input')
- })
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), '.*')
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), 'a_mismatching_input')
- await act(async () => await user.click(screen.getByText('create_wallet.button_create')))
+ await user.click(screen.getByText('create_wallet.button_create'))
expect(await screen.findByText('create_wallet.button_create')).toBeVisible()
expect(await screen.queryByText('create_wallet.feedback_invalid_wallet_name')).not.toBeInTheDocument()
@@ -143,20 +137,16 @@ describe('', () => {
}),
)
- act(() => setup({}))
+ setup({})
expect(await screen.findByText('create_wallet.button_create')).toBeVisible()
expect(await screen.queryByText('create_wallet.title_wallet_created')).not.toBeInTheDocument()
- await act(async () => {
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- })
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- await act(async () => {
- await user.click(screen.getByText('create_wallet.button_create'))
- })
+ await user.click(screen.getByText('create_wallet.button_create'))
expect(screen.getByText('create_wallet.title_wallet_created')).toBeVisible()
expect(screen.queryByText('create_wallet.button_create')).not.toBeInTheDocument()
@@ -175,29 +165,23 @@ describe('', () => {
}),
)
- act(() => setup({}))
+ setup({})
- await act(async () => {
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- })
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- await act(async () => {
- const createWalletButton = screen.getByText('create_wallet.button_create')
- await user.click(createWalletButton)
- })
+ const createWalletButton = screen.getByText('create_wallet.button_create')
+ await user.click(createWalletButton)
- await act(async () => {
- const revealToggle = await screen.findByText('create_wallet.confirmation_toggle_reveal_info')
- await user.click(revealToggle)
+ const revealToggle = await screen.findByText('create_wallet.confirmation_toggle_reveal_info')
+ await user.click(revealToggle)
- const confirmToggle = screen.getByText('create_wallet.confirmation_toggle_info_written_down')
- await user.click(confirmToggle)
+ const confirmToggle = screen.getByText('create_wallet.confirmation_toggle_info_written_down')
+ await user.click(confirmToggle)
- const nextButton = screen.getByText('create_wallet.next_button')
- await user.click(nextButton)
- })
+ const nextButton = screen.getByText('create_wallet.next_button')
+ await user.click(nextButton)
expect(screen.queryByText('create_wallet.skip_button')).not.toBeInTheDocument()
expect(screen.getByText('create_wallet.back_button')).toBeVisible()
@@ -216,29 +200,23 @@ describe('', () => {
}),
})
- act(() => setup({}))
+ setup({})
- await act(async () => {
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
- await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- })
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword)
+ await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword)
- await act(async () => {
- const createWalletButton = screen.getByText('create_wallet.button_create')
- await user.click(createWalletButton)
- })
+ const createWalletButton = screen.getByText('create_wallet.button_create')
+ await user.click(createWalletButton)
- await act(async () => {
- const revealToggle = await screen.findByText('create_wallet.confirmation_toggle_reveal_info')
- await user.click(revealToggle)
+ const revealToggle = await screen.findByText('create_wallet.confirmation_toggle_reveal_info')
+ await user.click(revealToggle)
- const confirmToggle = screen.getByText('create_wallet.confirmation_toggle_info_written_down')
- await user.click(confirmToggle)
+ const confirmToggle = screen.getByText('create_wallet.confirmation_toggle_info_written_down')
+ await user.click(confirmToggle)
- const nextButton = screen.getByText('create_wallet.next_button')
- await user.click(nextButton)
- })
+ const nextButton = screen.getByText('create_wallet.next_button')
+ await user.click(nextButton)
expect(screen.getByText('create_wallet.skip_button')).toBeVisible()
expect(screen.getByText('create_wallet.back_button')).toBeVisible()
diff --git a/src/components/Wallet.test.tsx b/src/components/Wallet.test.tsx
index be5912aa..d64a709b 100644
--- a/src/components/Wallet.test.tsx
+++ b/src/components/Wallet.test.tsx
@@ -1,8 +1,10 @@
import { BrowserRouter } from 'react-router-dom'
-import { render, screen, waitFor, act } from '@testing-library/react'
+import { render, screen, act } from '@testing-library/react'
import user from '@testing-library/user-event'
-import * as apiMock from '../libs/JmWalletApi'
+import { I18nextProvider } from 'react-i18next'
+import i18n from '../i18n/testConfig'
import { walletDisplayName } from '../utils'
+import * as apiMock from '../libs/JmWalletApi'
import Wallet, { WalletProps } from './Wallet'
@@ -28,16 +30,18 @@ describe('', () => {
coinjoinInProgress = false,
}: WalletProps) => {
render(
-
-
- ,
+
+
+
+
+ ,
)
}
@@ -67,15 +71,11 @@ describe('', () => {
expect(screen.queryByText('wallets.wallet_preview.button_open')).not.toBeInTheDocument()
expect(screen.queryByText('wallets.wallet_preview.button_lock')).not.toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
- await user.paste(dummyPassword)
- })
+ await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
+ await user.paste(dummyPassword)
- await act(async () => {
- const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
- await user.click(unlockWalletButton)
- })
+ const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
+ await user.click(unlockWalletButton)
expect(mockUnlockWallet).toHaveBeenCalledWith(dummyWalletFileName, dummyPassword)
})
@@ -126,10 +126,8 @@ describe('', () => {
expect(screen.getByText('wallets.wallet_preview.wallet_unlocked')).toBeInTheDocument()
expect(screen.getByText('wallets.wallet_preview.button_lock')).toBeInTheDocument()
- await act(async () => {
- const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
- await user.click(lockWalletButton)
- })
+ const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
+ await user.click(lockWalletButton)
expect(mockLockWallet).toHaveBeenCalledWith(dummyWalletFileName, { confirmed: false })
})
diff --git a/src/components/Wallets.test.tsx b/src/components/Wallets.test.tsx
index 1d864bc0..315cc5c0 100644
--- a/src/components/Wallets.test.tsx
+++ b/src/components/Wallets.test.tsx
@@ -47,7 +47,7 @@ describe('', () => {
;(apiMock.getSession as jest.Mock).mockReturnValue(neverResolvingPromise)
;(apiMock.getWalletAll as jest.Mock).mockReturnValue(neverResolvingPromise)
- await act(async () => setup({}))
+ setup({})
expect(screen.getByText('wallets.title')).toBeInTheDocument()
expect(screen.getByText('wallets.text_loading')).toBeInTheDocument()
@@ -249,15 +249,11 @@ describe('', () => {
expect(screen.getByText('wallets.wallet_preview.button_unlock')).toBeInTheDocument()
expect(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password')).toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
- await user.paste(dummyPassword)
- })
+ await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
+ await user.paste(dummyPassword)
- await act(async () => {
- const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
- await user.click(unlockWalletButton)
- })
+ const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
+ await user.click(unlockWalletButton)
expect(mockStartWallet).toHaveBeenCalledWith(dummyWalletFileName, {
token: dummyToken,
@@ -300,15 +296,10 @@ describe('', () => {
expect(screen.getByText('wallets.wallet_preview.button_unlock')).toBeInTheDocument()
expect(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password')).toBeInTheDocument()
- await act(async () => {
- await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
- await user.paste(dummyPassword)
- })
-
- await act(async () => {
- const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
- await user.click(unlockWalletButton)
- })
+ await user.click(screen.getByPlaceholderText('wallets.wallet_preview.placeholder_password'))
+ await user.paste(dummyPassword)
+ const unlockWalletButton = screen.getByText('wallets.wallet_preview.button_unlock')
+ await user.click(unlockWalletButton)
expect(mockStartWallet).not.toHaveBeenCalled()
expect(mockedNavigate).not.toHaveBeenCalled()
@@ -355,10 +346,8 @@ describe('', () => {
expect(screen.getByText('wallets.wallet_preview.wallet_unlocked')).toBeInTheDocument()
expect(screen.getByText('wallets.wallet_preview.button_lock')).toBeInTheDocument()
- await act(async () => {
- const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
- await user.click(lockWalletButton)
- })
+ const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
+ await user.click(lockWalletButton)
expect(mockStopWallet).toHaveBeenCalled()
expect(screen.getByText('wallets.wallet_preview.alert_wallet_locked_successfully')).toBeInTheDocument()
@@ -406,10 +395,8 @@ describe('', () => {
expect(screen.getByText('wallets.wallet_preview.wallet_unlocked')).toBeInTheDocument()
expect(screen.getByText('wallets.wallet_preview.button_lock')).toBeInTheDocument()
- await act(async () => {
- const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
- await user.click(lockWalletButton)
- })
+ const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
+ await user.click(lockWalletButton)
await waitFor(() => screen.findByText('wallets.wallet_preview.button_lock'))
@@ -464,11 +451,9 @@ describe('', () => {
expect(screen.queryByText('wallets.wallet_preview.modal_lock_wallet_title')).not.toBeInTheDocument()
expect(screen.getByText('wallets.wallet_preview.button_lock')).toBeInTheDocument()
- await act(async () => {
- // click on the "lock" button
- const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
- await user.click(lockWalletButton)
- })
+ // click on the "lock" button
+ const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
+ await user.click(lockWalletButton)
// modal appeared
expect(screen.getByText('wallets.wallet_preview.modal_lock_wallet_title')).toBeInTheDocument()
@@ -476,27 +461,21 @@ describe('', () => {
expect(screen.getByText('modal.confirm_button_accept')).toBeInTheDocument()
expect(screen.getByText('modal.confirm_button_reject')).toBeInTheDocument()
- await act(async () => {
- // click on the modal's "cancel" button
- const lockWalletButton = screen.getByText('modal.confirm_button_reject')
- await user.click(lockWalletButton)
- })
+ // click on the modal's "cancel" button
+ const modalCancelButton = screen.getByText('modal.confirm_button_reject')
+ await user.click(modalCancelButton)
expect(mockStopWallet).not.toHaveBeenCalled()
- await act(async () => {
- const lockWalletButton = screen.getByText('wallets.wallet_preview.button_lock')
- await user.click(lockWalletButton)
- })
+ const lockWalletButton2 = screen.getByText('wallets.wallet_preview.button_lock')
+ await user.click(lockWalletButton2)
// modal appeared
expect(screen.getByText('wallets.wallet_preview.modal_lock_wallet_title')).toBeInTheDocument()
- await act(async () => {
- // click on the modal's "confirm" button
- const lockWalletButton = screen.getByText('modal.confirm_button_accept')
- await user.click(lockWalletButton)
- })
+ // click on the modal's "confirm" button
+ const modalConfirmButton = screen.getByText('modal.confirm_button_accept')
+ await user.click(modalConfirmButton)
expect(mockStopWallet).toHaveBeenCalled()
},
diff --git a/src/components/fb/LockdateForm.test.tsx b/src/components/fb/LockdateForm.test.tsx
index a2c25b04..5360b815 100644
--- a/src/components/fb/LockdateForm.test.tsx
+++ b/src/components/fb/LockdateForm.test.tsx
@@ -1,18 +1,24 @@
-import { act, render, screen } from '../../testUtils'
+import { render, screen } from '@testing-library/react'
import user from '@testing-library/user-event'
+import { I18nextProvider } from 'react-i18next'
import * as Api from '../../libs/JmWalletApi'
import * as fb from './utils'
+import i18n from '../../i18n/testConfig'
import LockdateForm, { _minMonth, _selectableMonths, _selectableYears } from './LockdateForm'
describe('', () => {
const now = new Date(Date.UTC(2009, 0, 3))
const setup = (onChange: (lockdate: Api.Lockdate | null) => void) => {
- render()
+ render(
+
+
+ ,
+ )
}
it('should render without errors', () => {
- act(() => setup(() => {}))
+ setup(() => {})
expect(screen.getByTestId('select-lockdate-year')).toBeVisible()
expect(screen.getByTestId('select-lockdate-month')).toBeVisible()
@@ -21,7 +27,7 @@ describe('', () => {
it('should initialize 3 month ahead by default', () => {
const onChange = jest.fn()
- act(() => setup(onChange))
+ setup(onChange)
expect(onChange).toHaveBeenCalledWith(fb.lockdate.initial(now))
})
@@ -33,15 +39,15 @@ describe('', () => {
let selectedLockdate: Api.Lockdate | null = null
const onChange = (lockdate: Api.Lockdate | null) => (selectedLockdate = lockdate)
- act(() => setup(onChange))
+ setup(onChange)
const yearDropdown = screen.getByTestId('select-lockdate-year')
for (let i = 0; i < expectedSelectableYears; i++) {
const yearValue = currentYear + i
- await act(async () => {
- await user.selectOptions(yearDropdown, [`${yearValue}`])
- })
+
+ await user.selectOptions(yearDropdown, [`${yearValue}`])
+
expect(new Date(fb.lockdate.toTimestamp(selectedLockdate!)).getUTCFullYear()).toBe(yearValue)
}
@@ -50,7 +56,6 @@ describe('', () => {
await user.selectOptions(yearDropdown, [unavailableYearPast])
expect(false).toBe(true)
} catch (err: any) {
- console.log(JSON.stringify(err))
expect(err.name).toBe('TestingLibraryElementError')
}
@@ -70,21 +75,21 @@ describe('', () => {
let selectedLockdate: Api.Lockdate | null = null
const onChange = (lockdate: Api.Lockdate | null) => (selectedLockdate = lockdate)
- act(() => setup(onChange))
+ setup(onChange)
const initialLockdate = selectedLockdate
expect(initialLockdate).not.toBeNull()
const monthDropdown = screen.getByTestId('select-lockdate-month')
- await act(async () => await user.selectOptions(monthDropdown, [`${currentMonth}`]))
+ await user.selectOptions(monthDropdown, [`${currentMonth}`])
expect(selectedLockdate).toBe(initialLockdate) // select lockdate has not changed
const expectedLockdate = fb.lockdate.fromTimestamp(Date.UTC(currentYear, currentMonth + 3 - 1))
- await act(async () => await user.selectOptions(monthDropdown, [`${currentMonth + 3}`]))
+ await user.selectOptions(monthDropdown, [`${currentMonth + 3}`])
expect(selectedLockdate).toBe(expectedLockdate)
- await act(async () => await user.selectOptions(monthDropdown, [`${currentMonth}`]))
+ await user.selectOptions(monthDropdown, [`${currentMonth}`])
expect(selectedLockdate).toBe(expectedLockdate) // select lockdate has not changed
})