test: mock quotes to avoid errors logged (#7031)

This commit is contained in:
cartcrom 2023-07-28 11:39:49 -04:00 committed by GitHub
parent 1fde2504b4
commit f55062f9a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 7 deletions

@ -4,8 +4,7 @@ import { act, render, screen } from 'test-utils/render'
import SwapDetailsDropdown from './SwapDetailsDropdown' import SwapDetailsDropdown from './SwapDetailsDropdown'
// TODO(WEB-2120): Reenable tests after mocking trade fetch in this file describe('SwapDetailsDropdown.tsx', () => {
describe.skip('SwapDetailsDropdown.tsx', () => {
it('renders a trade', () => { it('renders a trade', () => {
const { asFragment } = render( const { asFragment } = render(
<SwapDetailsDropdown <SwapDetailsDropdown

@ -235,7 +235,13 @@ exports[`SwapDetailsDropdown.tsx renders a trade 1`] = `
<div <div
class="c14 css-zhpkf8" class="c14 css-zhpkf8"
> >
$1.00 <div
class="c2 c11"
>
<div>
$1.00
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -288,9 +294,15 @@ exports[`SwapDetailsDropdown.tsx renders a trade 1`] = `
</div> </div>
</div> </div>
<div <div
class="c9 css-zhpkf8" class="c10"
> >
~$1.00 <div>
<div
class="c9 css-zhpkf8"
>
~$1.00
</div>
</div>
</div> </div>
</div> </div>
<div <div
@ -301,7 +313,7 @@ exports[`SwapDetailsDropdown.tsx renders a trade 1`] = `
> >
<div> <div>
<div <div
class="c12 css-zhpkf8" class="c14 css-zhpkf8"
> >
Price Impact Price Impact
</div> </div>
@ -310,7 +322,7 @@ exports[`SwapDetailsDropdown.tsx renders a trade 1`] = `
<div <div
class="c9 css-zhpkf8" class="c9 css-zhpkf8"
> >
105566.37% 105566.373%
</div> </div>
</div> </div>
<div <div

@ -73,6 +73,20 @@ jest.mock('@web3-react/core', () => {
} }
}) })
jest.mock('state/routing/slice', () => {
const routingSlice = jest.requireActual('state/routing/slice')
return {
...routingSlice,
// Prevents unit tests from logging errors from failed getQuote queries
useGetQuoteQuery: () => ({
isError: false,
data: undefined,
error: undefined,
currentData: undefined,
}),
}
})
// Mocks are configured to reset between tests (by CRA), so they must be set in a beforeEach. // Mocks are configured to reset between tests (by CRA), so they must be set in a beforeEach.
beforeEach(() => { beforeEach(() => {
// Mock window.getComputedStyle, because it is otherwise too computationally expensive to unit test. // Mock window.getComputedStyle, because it is otherwise too computationally expensive to unit test.