mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
fix(auto-thumbnail): [PKG-AUTO-THUMB-09] restore historical default calls
This commit is contained in:
1 parent
c4f5dcf17f
commit
f30c701d88
29 files changed
+3331
-44
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert/strict'
|
||||
// eslint-disable-next-line test/no-import-node-test -- Native export compatibility regression runner.
|
||||
import test from 'node:test'
|
||||
import { autoThumbnailCandidate, autoThumbnailEnvironment } from './helpers/auto-thumbnail.js'
|
||||
|
||||
const implementation = await autoThumbnailCandidate()
|
||||
|
||||
for (const script of [false, true]) {
|
||||
test(`Auto-thumbnail ${script ? 'script global' : 'CommonJS'} keeps direct and historical default calls on one factory`, async () => {
|
||||
const env = autoThumbnailEnvironment(implementation, { script })
|
||||
const factory = env.factory
|
||||
assert.equal(typeof factory, 'function')
|
||||
assert.equal(factory.default, factory)
|
||||
assert.equal(factory.default.default, factory)
|
||||
assert.equal(env.videos.length, 0)
|
||||
const original = Object.getOwnPropertyDescriptor(factory, 'default')
|
||||
assert.deepEqual(original, { value: factory, writable: true, enumerable: true, configurable: true })
|
||||
const registrar = factory.default({ width: 80, number: 2 })
|
||||
const pending = registrar(env.art)
|
||||
assert.equal(pending.name, undefined)
|
||||
assert.equal(typeof pending.then, 'function')
|
||||
assert.deepEqual({ ...await pending }, { name: 'artplayerPluginAutoThumbnail' })
|
||||
assert.equal(env.videos.length, 0, 'Alias registration must not start extraction')
|
||||
env.art.emit('video:loadedmetadata')
|
||||
env.metadata()
|
||||
env.seeked()
|
||||
env.finish()
|
||||
assert.equal(env.updates.length, 1)
|
||||
assert.equal(env.updates[0].width, 80)
|
||||
env.art.emit('destroy')
|
||||
assert.equal(env.attached.size, 0)
|
||||
assert.equal(env.urls.size, 0)
|
||||
assert([...env.listeners.values()].every(callbacks => callbacks.size === 0))
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user