Skip to content

Commit 11b9288

Browse files
committed
fix: test hit
1 parent e995cb6 commit 11b9288

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/packages/backtop/__test__/backtop.spec.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@ import BackTop from '@/packages/backtop'
88
test('backtop props test', () => {
99
const handleClick = vi.fn()
1010
const { container } = render(
11-
<BackTop
12-
target="target"
13-
threshold={200}
14-
style={{
15-
right: '20px',
16-
bottom: '50px',
17-
}}
18-
onClick={handleClick}
19-
/>
11+
<div id="target" style={{ height: '100vh' }}>
12+
{new Array(24).fill(0).map((_, index) => {
13+
return <div key={index}>我是测试数据{index}</div>
14+
})}
15+
<BackTop
16+
target="target"
17+
className="backtop-button"
18+
onClick={handleClick}
19+
/>
20+
</div>
2021
)
21-
expect(container.querySelector('.nut-backtop')).toHaveAttribute(
22-
'style',
23-
'z-index: 900; right: 20px; bottom: 50px;'
24-
)
25-
fireEvent.click(container)
22+
const chooseTagEle = container.querySelectorAll('.backtop-button')[0]
23+
fireEvent.click(chooseTagEle)
2624
expect(handleClick).toBeCalled
2725
})
2826

0 commit comments

Comments
 (0)