diff --git a/src/apps/quicktime/QuickTime.vue b/src/apps/quicktime/QuickTime.vue index f5d7f08..8b05a30 100644 --- a/src/apps/quicktime/QuickTime.vue +++ b/src/apps/quicktime/QuickTime.vue @@ -1,42 +1,122 @@ + diff --git a/tests/cases/25-quicktime.test.ts b/tests/cases/25-quicktime.test.ts new file mode 100644 index 0000000..4674d59 --- /dev/null +++ b/tests/cases/25-quicktime.test.ts @@ -0,0 +1,43 @@ +/** + * 25-quicktime: QuickTime Vue 组件化测试 + * 覆盖: 播放器结构、视频列表、播放/暂停/上/下首、进度条、音量、卸载 + */ +import { describe, it, expect, beforeEach, afterEach } from 'vitest' +import { h, render, nextTick } from 'vue' +import QuickTimeComponent from '../../src/apps/quicktime/QuickTime.vue' +import { setupDOM } from '../helpers' + +function makeMockWin() { + const el = document.createElement('div'); el.className = 'window' + document.getElementById('window-layer')?.appendChild(el) + const body = document.createElement('div'); body.className = 'win-body' + el.appendChild(body) + return { id: 'qt', appId: 'quicktime', el, body, timers: [] as any[], data: {} } +} + +describe('25-quicktime — QuickTime Vue 组件化', () => { + let win: any + beforeEach(() => { setupDOM(); win = makeMockWin() }) + afterEach(() => { render(null, win.body); win.el.remove() }) + + function mount() { const v = h(QuickTimeComponent, { win }); render(v, win.body) } + + it('挂载后渲染播放器', () => { mount(); expect(win.body.querySelector('.qt-body')).toBeTruthy() }) + it('有播放/上/下首按钮', () => { + mount() + const btns = win.body.querySelectorAll('.qt-btn') + expect(btns.length).toBeGreaterThanOrEqual(3) + }) + it('有进度条和音量', () => { + mount() + expect(win.body.querySelector('.qt-seek')).toBeTruthy() + expect(win.body.querySelector('.qt-vol')).toBeTruthy() + }) + it('有视频播放区', () => { mount(); expect(win.body.querySelector('.qt-stage')).toBeTruthy() }) + it('暴露 toggle/nav 给菜单', () => { + mount() + expect(typeof win.appState.toggle).toBe('function') + expect(typeof win.appState.nav).toBe('function') + }) + it('卸载后 DOM 为空', () => { mount(); render(null, win.body); expect(win.body.children.length).toBe(0) }) +})