Skip to content

🧪 Add tests for joinUrls logic in utils.ts#521

Merged
sunnylqm merged 1 commit intomasterfrom
jules-13459560321360408866-8bfd1e29
Mar 3, 2026
Merged

🧪 Add tests for joinUrls logic in utils.ts#521
sunnylqm merged 1 commit intomasterfrom
jules-13459560321360408866-8bfd1e29

Conversation

@sunnylqm
Copy link
Contributor

@sunnylqm sunnylqm commented Mar 3, 2026

🧪 Testing Improvement: joinUrls logic

🎯 What: The testing gap addressed
The joinUrls logic inside src/utils.ts had no unit tests covering its simple but important mapping behavior for constructing update URLs. I have added bun:test unit tests specifically for joinUrls and introduced test setup configurations to ensure the required mocks (like react-native platform details and i18n translations) are safely provided during the test execution.

📊 Coverage: What scenarios are now tested

  • Valid paths and fileName combinations prepending https://
  • Missing fileName (returning undefined)
  • Empty array provided for paths (returning empty array)

Result: The improvement in test coverage
The code is thoroughly covered using bun test, confirming there's a safety net when anyone refactors the joinUrls utility. Run the unit tests suite exclusively via bun test src/.


PR created automatically by Jules for task 13459560321360408866 started by @sunnylqm

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests for utility functions and configured test environment setup to improve code reliability.

Adds unit tests and test suite configuration for testing src/utils.ts, achieving 100% test coverage for the joinUrls logic.

Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

The changes add test infrastructure to the project, including Bun configuration for test preloading, a test setup module that mocks external dependencies, and unit tests for a joinUrls utility function.

Changes

Cohort / File(s) Summary
Test Configuration
bunfig.toml
Adds test.preload configuration to preload setup module before tests run.
Test Setup Mocks
src/__tests__/setup.ts
Creates module mocks for react-native (Platform.OS = 'ios') and i18n (default t function returning input key).
Unit Tests
src/__tests__/utils.test.ts
Implements test suite for joinUrls utility with three test cases covering undefined fileName, empty paths, and URL construction with multiple paths and fileName.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A test setup script, so neat and bright,
With mocks for modules working just right,
joinUrls tested from path to domain,
Our code now robust, without any strain!
hops away with a test report 📋✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: adding tests for the joinUrls logic, which is the primary focus of all file modifications in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jules-13459560321360408866-8bfd1e29

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/__tests__/utils.test.ts (1)

1-17: Remove duplicated module mocks from this test file.

These mocks already exist in the preloaded src/__tests__/setup.ts; keeping both copies increases drift risk and maintenance overhead.

♻️ Proposed refactor
-import { describe, expect, test, mock } from 'bun:test';
+import { describe, expect, test } from 'bun:test';
 
-mock.module('react-native', () => {
-  return {
-    Platform: {
-      OS: 'ios',
-    },
-  };
-});
-
-mock.module('../i18n', () => {
-  return {
-    default: {
-      t: (key: string) => key,
-    },
-  };
-});
-
 import { joinUrls } from '../utils';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/__tests__/utils.test.ts` around lines 1 - 17, Remove the duplicated
module mocks in this test by deleting the mock.module('react-native', ...) and
mock.module('../i18n', ...) blocks from src/__tests__/utils.test.ts; these mocks
are already provided by the test preload in src/__tests__/setup.ts, so simply
remove the two mock.module declarations (the Platform OS mock and the i18n
default t mock) and leave the rest of the tests unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/__tests__/utils.test.ts`:
- Around line 1-17: Remove the duplicated module mocks in this test by deleting
the mock.module('react-native', ...) and mock.module('../i18n', ...) blocks from
src/__tests__/utils.test.ts; these mocks are already provided by the test
preload in src/__tests__/setup.ts, so simply remove the two mock.module
declarations (the Platform OS mock and the i18n default t mock) and leave the
rest of the tests unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7acce0d and d404305.

📒 Files selected for processing (3)
  • bunfig.toml
  • src/__tests__/setup.ts
  • src/__tests__/utils.test.ts

@sunnylqm sunnylqm merged commit 6e663b9 into master Mar 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant