test: ENG-03 share behavior fixtures across source and releases

This commit is contained in:
Harvey Zhao committed 2026-09-10 21:55:27 +08:00
1 parent b53461da1c
commit 458bc3215d
15 files changed
+260 -74

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { mock } from 'node:test'
export function playbackFactory({ Emitter, playMix, pauseMix, toggleMix, switchMix }) {
return function createArt(play = () => Promise.resolve(), playing = false) {
const art = Object.assign(new Emitter(), {
url: 'old.mp4',
currentTime: 37,
aspectRatio: '16:9',
playbackRate: 1.5,
notice: { show: '' },
i18n: { get: key => key },
option: { hotkey: true, mutex: false },
constructor: { instances: [] },
template: {
$video: {
paused: !playing,
play: mock.fn(play),
pause() { this.paused = true },
},
},
})
Object.defineProperty(art, 'playing', { get: () => !art.template.$video.paused })
for (const mix of [playMix, pauseMix, toggleMix, switchMix])
mix(art)
return art
}
}