FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
uniswap_interface_sc/apps/web/src/utils/urlRoutes.test.ts 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
/
utils
/
urlRoutes.test.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (68 loc) · 3.52 KB
Breadcrumbs
uniswap_interface_sc
/
apps
/
web
/
src
/
utils
/
urlRoutes.test.ts
Copy path
File metadata and controls
85 lines (68 loc) · 3.52 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import
{
InterfacePageName
}
from
'@uniswap/analytics-events'
import
{
getCanonicalUrl
,
getCurrentPageFromLocation
}
from
'utils/urlRoutes'
describe
(
'getCurrentPageFromLocation'
,
(
)
=>
{
it
(
'should return SWAP_PAGE when location pathname starts with "/swap"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/swap/123'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
SWAP_PAGE
)
}
)
it
(
'should return TOKEN_DETAILS_PAGE when location pathname starts with "/explore/tokens/:chainName/0x"'
,
(
)
=>
{
let
result
=
getCurrentPageFromLocation
(
'/explore/tokens/optimism/0x123'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
TOKEN_DETAILS_PAGE
)
result
=
getCurrentPageFromLocation
(
'/explore/tokens/polygon/NATIVE'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
TOKEN_DETAILS_PAGE
)
}
)
it
(
'should return POOL_DETAILS_PAGE when location pathname starts with "/explore/pools/0x"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/explore/pools/optimism/0x456'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
POOL_DETAILS_PAGE
)
}
)
it
(
'should return EXPLORE_PAGE when location pathname starts with "/explore" but does not match detail-page routes'
,
(
)
=>
{
let
result
=
getCurrentPageFromLocation
(
'/explore/tokens/ethereum'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
EXPLORE_PAGE
)
result
=
getCurrentPageFromLocation
(
'/explore/pools/optimism'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
EXPLORE_PAGE
)
}
)
it
(
'should return VOTE_PAGE when location pathname starts with "/vote"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/vote/456'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
VOTE_PAGE
)
}
)
it
(
'should return POOL_PAGE when location pathname starts with "/pools" or "/pool"'
,
(
)
=>
{
let
result
=
getCurrentPageFromLocation
(
'/pools/789'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
POOL_PAGE
)
result
=
getCurrentPageFromLocation
(
'/pool/abc'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
POOL_PAGE
)
}
)
it
(
'should return TOKENS_PAGE when location pathname starts with "/tokens"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/tokens/xyz'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
TOKENS_PAGE
)
}
)
it
(
'should return NFT_PROFILE_PAGE when location pathname starts with "/nfts/profile"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/nfts/profile/def'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
NFT_PROFILE_PAGE
)
}
)
it
(
'should return NFT_DETAILS_PAGE when location pathname starts with "/nfts/asset"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/nfts/asset/ghi'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
NFT_DETAILS_PAGE
)
}
)
it
(
'should return NFT_COLLECTION_PAGE when location pathname starts with "/nfts/collection"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/nfts/collection/jkl'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
NFT_COLLECTION_PAGE
)
}
)
it
(
'should return NFT_EXPLORE_PAGE when location pathname starts with "/nfts"'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/nfts/mno'
)
expect
(
result
)
.
toBe
(
InterfacePageName
.
NFT_EXPLORE_PAGE
)
}
)
it
(
'should return undefined for unknown location pathnames'
,
(
)
=>
{
const
result
=
getCurrentPageFromLocation
(
'/unknown'
)
expect
(
result
)
.
toBeUndefined
(
)
}
)
}
)
describe
(
'getCanonicalUrl'
,
(
)
=>
{
it
(
'should return the base URL as is'
,
(
)
=>
{
const
result
=
getCanonicalUrl
(
'/swap/123'
)
expect
(
result
)
.
toBe
(
'http://localhost/swap/123'
)
}
)
it
(
'should return the base URL without trailing slash'
,
(
)
=>
{
const
result
=
getCanonicalUrl
(
'/swap/123/'
)
expect
(
result
)
.
toBe
(
'http://localhost/swap/123'
)
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL