react-component / virtual-list

🧾 React Virtual List Component which worked with animation
https://rc-virtual-list.react-component.now.sh
MIT License
725 stars 154 forks source link

chore: not add attr #289

Closed zombieJ closed 1 month ago

zombieJ commented 1 month ago

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

Summary by CodeRabbit

vercel[bot] commented 1 month ago

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
coderabbitai[bot] commented 1 month ago

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 bea7eb4103d6eeb09bcedf8ce75cb590e16eb6b5 and 78ad219c42911cc1147863f6312e5f6d95aaca96.
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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: -- `I pushed a fix in commit , 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.