Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
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
vicotor
frontend
Commits
7efdf065
Commit
7efdf065
authored
Mar 31, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix jest tests
parent
b65ae1b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
setup.ts
jest/setup.ts
+12
-0
provider.tsx
toolkit/chakra/provider.tsx
+1
-0
useRatings.test.tsx
ui/marketplace/Rating/useRatings.test.tsx
+39
-3
No files found.
jest/setup.ts
View file @
7efdf065
...
@@ -41,3 +41,15 @@ global.console = {
...
@@ -41,3 +41,15 @@ global.console = {
consoleError
(...
args
);
consoleError
(...
args
);
},
},
};
};
// Polyfill for structuredClone
if
(
typeof
structuredClone
===
'
undefined
'
)
{
global
.
structuredClone
=
<
T
>
(
obj
:
T
):
T
=>
{
try
{
return
JSON
.
parse
(
JSON
.
stringify
(
obj
))
as
T
;
}
catch
(
error
)
{
// Fallback for circular references and other special cases
return
obj
;
}
};
}
toolkit/chakra/provider.tsx
View file @
7efdf065
'
use client
'
;
'
use client
'
;
import
{
ChakraProvider
}
from
'
@chakra-ui/react
'
;
import
{
ChakraProvider
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
theme
from
'
toolkit/theme/theme
'
;
import
theme
from
'
toolkit/theme/theme
'
;
...
...
ui/marketplace/Rating/useRatings.test.tsx
View file @
7efdf065
import
{
act
}
from
'
react
'
;
import
{
renderHook
,
wrapper
}
from
'
jest/lib
'
;
import
{
renderHook
,
wrapper
}
from
'
jest/lib
'
;
import
useRatings
from
'
./useRatings
'
;
import
useRatings
from
'
./useRatings
'
;
...
@@ -5,7 +7,11 @@ import useRatings from './useRatings';
...
@@ -5,7 +7,11 @@ import useRatings from './useRatings';
const
useAccount
=
jest
.
fn
();
const
useAccount
=
jest
.
fn
();
const
useApiQuery
=
jest
.
fn
();
const
useApiQuery
=
jest
.
fn
();
jest
.
mock
(
'
lib/hooks/useToast
'
,
()
=>
jest
.
fn
());
jest
.
mock
(
'
toolkit/chakra/toaster
'
,
()
=>
({
toaster
:
{
error
:
jest
.
fn
(),
},
}));
jest
.
mock
(
'
wagmi
'
,
()
=>
({
useAccount
:
()
=>
useAccount
()
}));
jest
.
mock
(
'
wagmi
'
,
()
=>
({
useAccount
:
()
=>
useAccount
()
}));
jest
.
mock
(
'
lib/api/useApiQuery
'
,
()
=>
()
=>
useApiQuery
());
jest
.
mock
(
'
lib/api/useApiQuery
'
,
()
=>
()
=>
useApiQuery
());
...
@@ -19,7 +25,12 @@ it('should set canRate to true if address is defined and transactions_count is 5
...
@@ -19,7 +25,12 @@ it('should set canRate to true if address is defined and transactions_count is 5
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
5
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
true
);
expect
(
result
.
current
.
canRate
).
toBe
(
true
);
});
});
...
@@ -29,7 +40,12 @@ it('should set canRate to undefined if address is undefined', async() => {
...
@@ -29,7 +40,12 @@ it('should set canRate to undefined if address is undefined', async() => {
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
5
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
undefined
);
expect
(
result
.
current
.
canRate
).
toBe
(
undefined
);
});
});
...
@@ -39,7 +55,12 @@ it('should set canRate to false if transactions_count is less than 5', async() =
...
@@ -39,7 +55,12 @@ it('should set canRate to false if transactions_count is less than 5', async() =
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{
transactions_count
:
4
},
data
:
{
transactions_count
:
4
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
});
});
...
@@ -49,7 +70,12 @@ it('should set canRate to false if isPlaceholderData is true', async() => {
...
@@ -49,7 +70,12 @@ it('should set canRate to false if isPlaceholderData is true', async() => {
isPlaceholderData
:
true
,
isPlaceholderData
:
true
,
data
:
{
transactions_count
:
5
},
data
:
{
transactions_count
:
5
},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
});
});
...
@@ -59,7 +85,12 @@ it('should set canRate to false if data is undefined', async() => {
...
@@ -59,7 +85,12 @@ it('should set canRate to false if data is undefined', async() => {
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
undefined
,
data
:
undefined
,
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
());
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
});
});
...
@@ -69,6 +100,11 @@ it('should set canRate to false if transactions_count is undefined', async() =>
...
@@ -69,6 +100,11 @@ it('should set canRate to false if transactions_count is undefined', async() =>
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
data
:
{},
data
:
{},
});
});
const
{
result
}
=
renderHook
(()
=>
useRatings
());
const
{
result
}
=
renderHook
(()
=>
useRatings
(),
{
wrapper
});
await
act
(
async
()
=>
{
await
Promise
.
resolve
();
});
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
expect
(
result
.
current
.
canRate
).
toBe
(
false
);
});
});
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