mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
test: ENG-03 share behavior fixtures across source and releases
This commit is contained in:
1 parent
b53461da1c
commit
458bc3215d
15 files changed
+260
-74
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user