Skip to content

chore: not add attr #289

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

Merged
merged 1 commit into from
Sep 20, 2024
Merged

chore: not add attr #289

merged 1 commit into from
Sep 20, 2024

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 20, 2024

调整测试方式,以避免添加额外的属性上来

Summary by CodeRabbit

  • Bug Fixes

    • 移除了在非生产环境中设置 data-dev-offset-top 属性的条件块,简化了 containerProps 的属性分配。
  • Tests

    • ScrollBar 组件引入了新的模拟实现,更新了测试断言以检查新的 data-dev-offset 属性。

Copy link

vercel bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
virtual-list ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 11:54am

Copy link

coderabbitai bot commented Sep 20, 2024

Walkthrough

此次更改主要涉及对ScrollBar组件的模拟实现进行更新,以便在测试中使用新的data-dev-offset属性。同时,移除了在非生产环境下为containerProps对象设置data-dev-offset-top属性的条件块,从而简化了RawList函数中的属性赋值。这些更改未对导出或公共实体的声明产生影响。

Changes

文件 更改摘要
src/List.tsx 移除了在非生产环境下设置data-dev-offset-top属性的条件块,简化了containerProps的赋值。
tests/scroll.test.js 引入了ScrollBar组件的模拟实现,更新了测试断言以检查新的data-dev-offset属性,替换了对data-dev-offset-top的检查。
tests/touch.test.js 引入了ScrollBar组件的模拟实现,更新了测试断言以检查data-dev-offset属性的存在,替换了对data-dev-offset-top的检查。

Poem

🐰 在代码的花园里,
变化如春风拂面,
data-dev-offset新生,
测试如花般绽放,
兔子欢呼,乐无边!
让我们一起跳跃,
迎接更美好的明天! 🌼


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bea7eb4 and 78ad219.

Files selected for processing (3)
  • src/List.tsx (0 hunks)
  • tests/scroll.test.js (2 hunks)
  • tests/touch.test.js (2 hunks)
Files not reviewed due to no reviewable changes (1)
  • src/List.tsx
Additional comments not posted (5)
tests/touch.test.js (3)

7-20: 代码看起来不错!

模拟 ScrollBar 组件并添加 data-dev-offset 属性来验证 scrollOffset prop 是一个很好的测试方法。这种方法可以让我们在测试中方便地检查滚动偏移量。


179-182: 断言看起来正确!

这个断言验证了内部列表没有滚动到顶部(偏移量不等于'0'),这是预期的行为。测试用例覆盖了嵌套列表的滚动场景,非常全面。


186-188: 外部列表滚动断言正确!

这个断言验证了外部列表滚动到了顶部(偏移量等于'0'),符合预期。结合之前对内部列表的断言,这个测试用例很好地覆盖了嵌套列表的滚动行为。

tests/scroll.test.js (2)

14-28: LGTM!

这个 mock 实现看起来很棒。它通过将原始的 ScrollBar 组件包装在一个 div 元素中,并在 div 上添加一个反映 scrollOffset prop 的 data-dev-offset 属性,使得在受控环境中测试 ScrollBar 组件的行为变得更加容易。这个改动提高了 ScrollBar 组件的可测试性。


543-553: 测试用例看起来很全面!

这个测试用例很好地覆盖了嵌套滚动的场景。通过在内部滚动容器上触发滚轮事件,并断言内部容器的 data-dev-offset 属性值为 '10',外部容器的 data-dev-offset 属性值为 '0',确保了滚动偏移量正确地传播到内部容器,而不会影响外部容器。这个测试确保了嵌套滚动的行为符合预期,并且不会干扰父级滚动容器。


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    -- @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 generate unit testing code.
    -- @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.

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 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 the configuration 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 our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.47%. Comparing base (bea7eb4) to head (78ad219).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #289      +/-   ##
==========================================
- Coverage   98.48%   98.47%   -0.01%     
==========================================
  Files          18       18              
  Lines         725      723       -2     
  Branches      175      174       -1     
==========================================
- Hits          714      712       -2     
  Misses         11       11              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zombieJ zombieJ merged commit 52f20db into master Sep 20, 2024
12 checks passed
@zombieJ zombieJ deleted the adjust-test branch September 20, 2024 11:58
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