FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
uniswap_interface_sc/apps/web/src/test-utils/render.tsx at main · stringcode86/uniswap_interface_sc · GitHub
stringcode86
uniswap_interface_sc
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
uniswap_interface_sc
/
apps
/
web
/
src
/
test-utils
/
render.tsx
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (64 loc) · 2.95 KB
Breadcrumbs
uniswap_interface_sc
/
apps
/
web
/
src
/
test-utils
/
render.tsx
Copy path
File metadata and controls
70 lines (64 loc) · 2.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import
{
MockedProvider
}
from
'@apollo/client/testing'
import
{
QueryClient
,
QueryClientProvider
}
from
'@tanstack/react-query'
import
{
queries
}
from
'@testing-library/dom'
import
{
RenderOptions
,
render
}
from
'@testing-library/react'
import
{
RenderHookOptions
,
WrapperComponent
,
renderHook
}
from
'@testing-library/react-hooks'
import
Web3Provider
from
'components/Web3Provider'
import
{
AssetActivityProvider
}
from
'graphql/data/apollo/AssetActivityProvider'
import
{
TokenBalancesProvider
}
from
'graphql/data/apollo/TokenBalancesProvider'
import
{
BlockNumberContext
}
from
'lib/hooks/useBlockNumber'
import
{
PropsWithChildren
,
ReactElement
,
ReactNode
}
from
'react'
import
{
HelmetProvider
}
from
'react-helmet-async/lib/index'
import
{
Provider
}
from
'react-redux'
import
{
BrowserRouter
}
from
'react-router-dom'
import
store
from
'state'
import
{
ThemeProvider
}
from
'theme'
import
{
TamaguiProvider
}
from
'theme/tamaguiProvider'
import
{
UnitagUpdaterContextProvider
}
from
'uniswap/src/features/unitags/context'
const
queryClient
=
new
QueryClient
(
)
const
BLOCK_NUMBER_CONTEXT
=
{
fastForward
:
(
)
=>
{
}
,
block
:
1234
,
mainnetBlock
:
1234
}
function
MockedBlockNumberProvider
(
{
children
}
:
PropsWithChildren
)
{
return
<
BlockNumberContext
.
Provider
value
=
{
BLOCK_NUMBER_CONTEXT
}
>
{
children
}
</
BlockNumberContext
.
Provider
>
}
const
WithProviders
=
(
{
children
}
:
{
children
?:
ReactNode
}
)
=>
{
return
(
<
HelmetProvider
>
<
Provider
store
=
{
store
}
>
<
QueryClientProvider
client
=
{
queryClient
}
>
<
BrowserRouter
>
<
Web3Provider
>
<
MockedProvider
showWarnings
=
{
false
}
>
<
AssetActivityProvider
>
<
TokenBalancesProvider
>
<
MockedBlockNumberProvider
>
<
UnitagUpdaterContextProvider
>
<
ThemeProvider
>
<
TamaguiProvider
>
{
children
}
</
TamaguiProvider
>
</
ThemeProvider
>
</
UnitagUpdaterContextProvider
>
</
MockedBlockNumberProvider
>
</
TokenBalancesProvider
>
</
AssetActivityProvider
>
</
MockedProvider
>
</
Web3Provider
>
</
BrowserRouter
>
</
QueryClientProvider
>
</
Provider
>
</
HelmetProvider
>
)
}
type
CustomRenderOptions
=
Omit
<
RenderOptions
,
'wrapper'
>
const
customRender
=
(
ui
:
ReactElement
,
options
?:
CustomRenderOptions
)
=>
{
return
render
<
typeof
queries
>
(
ui
,
{
...
options
,
wrapper
:
WithProviders
}
)
}
type
CustomRenderHookOptions
<
Props
>
=
Omit
<
RenderHookOptions
<
Props
>
,
'wrapper'
>
const
customRenderHook
=
<
Result
,
Props
>
(
hook
:
(
initialProps
:
Props
)
=>
Result
,
options
?:
CustomRenderHookOptions
<
Props
>
,
)
=>
{
return
renderHook
(
hook
,
{
...
options
,
wrapper
:
WithProviders
as
WrapperComponent
<
Props
>
}
)
}
// Testing utils may export *.
// eslint-disable-next-line no-restricted-syntax
export
*
from
'@testing-library/react'
export
{
customRender
as
render
,
customRenderHook
as
renderHook
}
Back
|
FazBrowse Home
|
New Git URL