Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
22688606
Unverified
Commit
22688606
authored
Apr 20, 2023
by
Zach Pomerantz
Committed by
GitHub
Apr 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: web3 (#6299)
* build: upgrade web3-react@^8.2 * test: web3 * fix: update test name
parent
9c41955e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
index.test.tsx
src/components/Web3Provider/index.test.tsx
+48
-0
No files found.
src/components/Web3Provider/index.test.tsx
0 → 100644
View file @
22688606
import
{
act
,
render
}
from
'
@testing-library/react
'
import
{
initializeConnector
,
MockEIP1193Provider
}
from
'
@web3-react/core
'
import
{
EIP1193
}
from
'
@web3-react/eip1193
'
import
{
Provider
as
EIP1193Provider
}
from
'
@web3-react/types
'
import
{
Connection
,
ConnectionType
}
from
'
connection
'
import
useEagerlyConnect
from
'
hooks/useEagerlyConnect
'
import
useOrderedConnections
from
'
hooks/useOrderedConnections
'
import
{
Provider
}
from
'
react-redux
'
import
store
from
'
state
'
import
{
mocked
}
from
'
test-utils/mocked
'
import
Web3Provider
from
'
.
'
jest
.
mock
(
'
hooks/useEagerlyConnect
'
,
()
=>
jest
.
fn
())
jest
.
mock
(
'
hooks/useOrderedConnections
'
,
()
=>
jest
.
fn
())
const
UI
=
(
<
Provider
store=
{
store
}
>
<
Web3Provider
>
{
null
}
</
Web3Provider
>
</
Provider
>
)
describe
(
'
Web3Provider
'
,
()
=>
{
let
provider
:
MockEIP1193Provider
&
EIP1193Provider
let
connection
:
Connection
beforeEach
(()
=>
{
provider
=
new
MockEIP1193Provider
()
as
MockEIP1193Provider
&
EIP1193Provider
const
[
connector
,
hooks
]
=
initializeConnector
((
actions
)
=>
new
EIP1193
({
actions
,
provider
}))
connection
=
{
connector
,
hooks
,
getName
:
jest
.
fn
().
mockReturnValue
(
'
test
'
),
type
:
'
INJECTED
'
as
ConnectionType
,
shouldDisplay
:
()
=>
false
,
}
mocked
(
useOrderedConnections
).
mockReturnValue
([
connection
])
})
it
(
'
renders and eagerly connects
'
,
async
()
=>
{
const
result
=
render
(
UI
)
await
act
(
async
()
=>
{
await
result
})
expect
(
useEagerlyConnect
).
toHaveBeenCalled
()
expect
(
result
).
toBeTruthy
()
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment