Skip to content

Commit

Permalink
Merge pull request #15 from hanhan9449/test/221001_unit_test_case_opt
Browse files Browse the repository at this point in the history
测试用例优化
  • Loading branch information
hanhan9449 committed Oct 1, 2022
2 parents 599e614 + 46f9096 commit 0b2546e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/hooks/useDebounce.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const Test: FC = () => {
const [value, setValue] = useState(0)
function updateValue() {
act(() => {
setValue(p => p + 1)
// 函数直接使用state值的场景
// value仍然能取到最新的值
setValue(value + 1)
})
}
const debouncedUpdateValue = useDebounce(updateValue, 1000)
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useThrottle.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const Test: FC = () => {
const [value, setValue] = useState(0)
function updateValue() {
act(() => {
setValue(p => p + 1)
// 函数直接使用state值的场景
// value仍然能取到最新的值
setValue(value + 1)
})
}
const debouncedUpdateValue = useThrottle(updateValue, 1000)
Expand Down

0 comments on commit 0b2546e

Please sign in to comment.