-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add unit test for src/utils/server/geo.ts #5913
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
👍 @gru-agent[bot] Thank you for raising your pull request and contributing to our Community |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5913 +/- ##
=======================================
Coverage 92.40% 92.40%
=======================================
Files 660 661 +1
Lines 59837 59876 +39
Branches 2805 2812 +7
=======================================
+ Hits 55291 55330 +39
Misses 4546 4546
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
✅ Rebase TestGru PR Success
|
79b6c10
to
b809cbf
Compare
🔄 Rebasing Testgru per ... |
✅ Rebase TestGru PR Success
|
b809cbf
to
85d4c7b
Compare
🔄 Rebasing Testgru per ... |
✅ Rebase TestGru PR Success
|
85d4c7b
to
8f2f1a9
Compare
Deployment failed with the following error:
|
🔄 Rebasing Testgru per ... |
✅ Rebase TestGru PR Success
|
8f2f1a9
to
8596e57
Compare
Deployment failed with the following error:
|
🔄 Rebasing Testgru per ... |
@gru-agent 回滚 Dockerfile 的变更 |
@gru-agent Rollback Dockerfile changes |
@gru-agent redo |
✅ Rebase TestGru PR Success
|
🔄 Rebasing Testgru per ... |
284d12f
to
4342b53
Compare
Trigger Info
Summary
This PR introduces unit tests for the
parseDefaultThemeFromCountry
function in thegeo
utility module. The tests ensure that the function correctly determines the default theme (light or dark) based on the country and its associated timezone. Key highlights include:Mocking Dependencies: The
countries-and-timezones
library is mocked to simulate country and timezone data.Test Scenarios:
Default to light theme when no country code or timezone information is available.
Correctly extract country codes from various headers (
x-vercel-ip-country
,cf-ipcountry
, etc.) orrequest.geo
.Validate theme selection based on local time (daytime hours: 6-18 for light theme, nighttime hours for dark theme).
Handle edge cases at 6:00 and 18:00 local time.
Time Manipulation:
vi.useFakeTimers
is used to simulate specific times for testing.These tests improve confidence in the function's behavior across different scenarios and edge cases.
Tip
You can
@gru-agent
and leave your feedback. TestGru will make adjustments based on your inputTip
You can
@gru-agent rebase
to rebase the PR.Tip
You can
@gru-agent redo
to reset or rebase before redoing the PR.Tip
To modify the test code yourself, click here Edit Test Code