Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add escapeRegExp tests#2809

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
huan wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromcodex/add-tests-for-escape-regexp

Conversation

@huan
Copy link
Member

@huanhuan commentedJun 17, 2025
edited by coderabbitaibot
Loading

Summary

  • add unit tests forescapeRegExp

Testing

  • npm run test:unit(fails: cross-env not found)

https://chatgpt.com/codex/tasks/task_e_685118b4466c8324a7b93ba6fbedaced


Important

Add unit tests forescapeRegExp to verify handling of typical strings and regex special characters.

  • Tests:
    • Add unit tests forescapeRegExp inescape-regexp.spec.ts.
    • TestescapeRegExp() with typical strings to ensure they remain unchanged.
    • TestescapeRegExp() with regex special characters to ensure they are escaped with backslashes.

This description was created byEllipsis fordbc12c9. You cancustomize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Tests
    • Added new tests to verify correct handling and escaping of regular expression special characters.

ellipsis-dev[bot] reacted with rocket emoji
@coderabbitai
Copy link

coderabbitaibot commentedJun 17, 2025
edited
Loading

Walkthrough

A new test file was introduced to validate the behavior of theescapeRegExp function. The tests use thetstest framework to confirm that the function correctly handles both regular strings and strings containing regex special characters.

Changes

File(s)Change Summary
src/pure-functions/escape-regexp.spec.tsAdded new test cases for theescapeRegExp function

Poem

A rabbit hopped with specs in hand,
Testing regex through the land.
Special chars, no need to fear—
Backslashes now appear!
With tstest’s help, the code is tight,
The function’s future’s looking bright.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

@dosubotdosubotbot added the size:MThis PR changes 30-99 lines, ignoring generated files. labelJun 17, 2025
Copy link

@ellipsis-devellipsis-devbot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up todbc12c9 in 42 seconds. Click for details.
  • Reviewed38 lines of code in1 files
  • Skipped0 files when reviewing.
  • Skipped posting2 draft comments. View those below.
  • Modify yoursettings andrules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1.src/pure-functions/escape-regexp.spec.ts:1
  • Draft comment:
    The shebang at the top is uncommon in test files. Consider removing it unless you require direct execution, as it might affect cross-platform compatibility.
  • Reason this comment was not posted:
    Confidence changes required:33% <= threshold50% None
2.src/pure-functions/escape-regexp.spec.ts:27
  • Draft comment:
    The tests cover typical strings and a full set of regex special characters. Consider adding additional edge cases (e.g. empty string, string with only special characters) to fully validate the function's behavior.
  • Reason this comment was not posted:
    Confidence changes required:33% <= threshold50% None

Workflow ID:wflow_UOhX1kQqW5uzMmY5

You can customizeEllipsis by changing yourverbosity settings, reacting with 👍 or 👎,replying to comments, or addingcode review rules.

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/pure-functions/escape-regexp.spec.ts (2)

21-25:Drop the unnecessaryasync wrapper to reduce overhead

escapeRegExp() is synchronous and the test body contains noawait.
Removingasync avoids wrapping the result in a (discarded) Promise and keeps the test definition minimal.

-test('escapeRegExp() with typical string', async t => {+test('escapeRegExp() with typical string', t => {

27-32:Expand the “special-char” case to include all characters the implementation escapes

The current input omits- and/, which are explicitly covered by the regex inescapeRegExp().
Adding them strengthens the regression-proof surface of the test without extra cost.

-  const input = '.*+?^${}()|[]\\'-  const expected = '\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\'+  const input = '.-*+/+?^${}()|[]\\'+  const expected = '\\.\\-\\*\\+\\/\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\'

Alternatively, add a third test dedicated to-/ so the current expectations stay readable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and betweened9ca01 anddbc12c9.

📒 Files selected for processing (1)
  • src/pure-functions/escape-regexp.spec.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/pure-functions/escape-regexp.spec.ts (1)
src/pure-functions/escape-regexp.ts (1)
  • escapeRegExp (20-22)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build
  • GitHub Check: Build

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ellipsis-devellipsis-dev[bot]ellipsis-dev[bot] left review comments

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

At least 3 approving reviews are required to merge this pull request.

Assignees

No one assigned

Labels

codexsize:MThis PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@huan

[8]ページ先頭

©2009-2025 Movatter.jp