diff --git a/src/packages/video/__tests__/video.spec.tsx b/src/packages/video/__tests__/video.spec.tsx index 4d1df68e9d..a75bd2a219 100644 --- a/src/packages/video/__tests__/video.spec.tsx +++ b/src/packages/video/__tests__/video.spec.tsx @@ -1,8 +1,9 @@ import * as React from 'react' -import { render } from '@testing-library/react' +import { render, fireEvent } from '@testing-library/react' import '@testing-library/jest-dom' import { Video } from '../video' +import Button from '@/packages/button' test('video base info', () => { const App = () => { @@ -26,3 +27,48 @@ test('video base info', () => { expect(sourceDom?.getAttribute('src')).toBe('xxx.mp4') expect(container).toMatchSnapshot() }) + +test('video ref call', () => { + const pause = vi.fn() + // 确保在每个测试后清理 mock + afterEach(() => { + pause.mockClear() + }) + const App = () => { + const source = { + src: 'xxx.mp4', + type: 'video/mp4', + } + const options = { + controls: true, + autoplay: true, + playsinline: true, + loop: true, + poster: + 'https://img12.360buyimg.com/ling/s345x208_jfs/t1/168105/33/8417/54825/603df06dEfcddc4cb/21f9f5d0a1b3dad4.jpg.webp', + } + const itemRef = React.useRef(null) + + return ( + <> +