overall cleanup and refactoring + SettingsModal (#286)

This commit is contained in:
Linkie Link
2023-07-11 21:01:14 +02:00
committed by GitHub
parent ffe86a440c
commit df6d7a3ba2
120 changed files with 1399 additions and 1135 deletions
@@ -1,11 +1,11 @@
import { render } from '@testing-library/react'
import { CircularProgress } from 'components/CircularProgress'
import useStore from 'store'
import { REDUCE_MOTION_KEY } from 'constants/localStore'
describe('<CircularProgress />', () => {
afterAll(() => {
useStore.clearState()
localStorage.removeItem(REDUCE_MOTION_KEY)
})
it('should render', () => {
@@ -15,7 +15,7 @@ describe('<CircularProgress />', () => {
})
it('should render `...` when animations disabled', () => {
useStore.setState({ enableAnimations: false })
localStorage.setItem(REDUCE_MOTION_KEY, 'true')
const { getByText } = render(<CircularProgress />)
const threeDots = getByText('...')
@@ -24,7 +24,7 @@ describe('<CircularProgress />', () => {
})
it('should render the component with animation classes when animations enabled', () => {
useStore.setState({ enableAnimations: true })
localStorage.setItem(REDUCE_MOTION_KEY, 'false')
const { container } = render(<CircularProgress />)
const progressWithAnimations = container.querySelector('.animate-progress')
@@ -1,6 +1,6 @@
import { render } from '@testing-library/react'
import LendingDetails from 'components/Earn/Lend/LendingDetails'
import LendingDetails from 'components/MarketAssetTable/MarketDetails'
import { ASSETS } from 'constants/assets'
import { BN } from 'utils/helpers'
@@ -1,13 +1,13 @@
import { render } from '@testing-library/react'
import Modal from 'components/Modal'
import UnlockModal from 'components/Modals/Unlock/UnlockModal'
import UnlockModal from 'components/Modals/Unlock'
import { TESTNET_VAULTS_META_DATA } from 'constants/vaults'
import useStore from 'store'
import { BN } from 'utils/helpers'
jest.mock('components/Modal')
const mockedModal = jest.mocked(Modal).mockImplementation(() => <div>Modal</div>)
const mockedModal = jest.mocked(Modal).mockImplementation(() => <div>Mock</div>)
const mockedDepositedVault: DepositedVault = {
...TESTNET_VAULTS_META_DATA[0],
@@ -36,31 +36,26 @@ const mockedDepositedVault: DepositedVault = {
}
describe('<UnlockModal />', () => {
beforeAll(() => {
useStore.setState({ unlockModal: null })
afterAll(() => {
useStore.clearState()
})
it('should render', () => {
const { container } = render(<UnlockModal />)
expect(mockedModal).toHaveBeenCalledTimes(1)
expect(container).toBeInTheDocument()
})
describe('should set open attribute correctly', () => {
it('should set open = false when no modal is present in store', () => {
describe('should set content correctly', () => {
it('should have no content when no modal is present in store', () => {
useStore.setState({ unlockModal: null })
render(<UnlockModal />)
expect(mockedModal).toHaveBeenCalledWith(
expect.objectContaining({ open: false }),
expect.anything(),
)
expect(mockedModal).toHaveBeenCalledTimes(0)
})
it('should set open = true when no modal is present in store', () => {
it('should have content when modal is present in store', () => {
useStore.setState({ unlockModal: { vault: mockedDepositedVault } })
render(<UnlockModal />)
expect(mockedModal).toHaveBeenLastCalledWith(
expect.objectContaining({ open: true }),
expect.anything(),
)
expect(mockedModal).toHaveBeenCalledTimes(1)
})
})
})