Closed zombieJ closed 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 |
此次更改主要涉及对ScrollBar
组件的模拟实现进行更新,以便在测试中使用新的data-dev-offset
属性。同时,移除了在非生产环境下为containerProps
对象设置data-dev-offset-top
属性的条件块,从而简化了RawList
函数中的属性赋值。这些更改未对导出或公共实体的声明产生影响。
文件 | 更改摘要 |
---|---|
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 的检查。 |
🐰 在代码的花园里,
变化如春风拂面,
data-dev-offset
新生,
测试如花般绽放,
兔子欢呼,乐无边!
让我们一起跳跃,
迎接更美好的明天! 🌼
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',确保了滚动偏移量正确地传播到内部容器,而不会影响外部容器。这个测试确保了嵌套滚动的行为符合预期,并且不会干扰父级滚动容器。
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.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
调整测试方式,以避免添加额外的属性上来
Summary by CodeRabbit
Bug Fixes
data-dev-offset-top
属性的条件块,简化了containerProps
的属性分配。Tests
ScrollBar
组件引入了新的模拟实现,更新了测试断言以检查新的data-dev-offset
属性。