mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
refactor(core): rework media config as a plain getter/setter (#1697)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { getComponents } from '@videojs/core/dom/media/media-host';
|
||||
import { MuxData } from '@videojs/core/dom/media/mux';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { MuxVideo } from '../mux-video';
|
||||
@@ -17,18 +18,31 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('MuxVideo', () => {
|
||||
it('exposes the mux data component config on element config', () => {
|
||||
it('constructs the mux data component with the player software name', () => {
|
||||
const el = createMuxVideo();
|
||||
const muxData = getComponents(el.host).get(MuxData);
|
||||
|
||||
expect(muxData).toBeInstanceOf(MuxData);
|
||||
expect(muxData?.playerSoftwareName).toBe('mux-video');
|
||||
});
|
||||
|
||||
it('exposes the element config as plain values, not the component instance', () => {
|
||||
const el = createMuxVideo();
|
||||
|
||||
expect(el.config.muxData).toBeInstanceOf(MuxData);
|
||||
expect((el.config.muxData as MuxData).playerSoftwareName).toBe('mux-video');
|
||||
// `config` reflects exactly what was set — a plain namespace bag.
|
||||
expect(el.config.muxData).toEqual({ MuxDataSdk: undefined });
|
||||
expect(el.config.muxData).not.toBeInstanceOf(MuxData);
|
||||
});
|
||||
|
||||
it('routes component config writes to the component', () => {
|
||||
const el = createMuxVideo();
|
||||
const muxData = getComponents(el.host).get(MuxData);
|
||||
|
||||
el.config = { muxData: { envKey: 'test-key' } };
|
||||
|
||||
// The write reached the live component...
|
||||
expect(muxData?.envKey).toBe('test-key');
|
||||
// ...and config reads back the plain value, not the instance.
|
||||
expect(el.config.muxData?.envKey).toBe('test-key');
|
||||
expect(el.hasAttribute('config')).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user