- Closes #2556 - Closes #2450 **Key intended features:** - go2rtc compatible - 100% test coverage to significantly improve ability to test, maintain and work around browser weirdnesses (e.g. Safari). - Written from the ground up in the style of the rest of the project. **To use:** - Change `live_provider` from `go2rtc` to `go2rtc-experimental`.
25 lines
808 B
TypeScript
25 lines
808 B
TypeScript
import { expect, it, vi } from 'vitest';
|
|
|
|
import { dispatchLiveErrorEvent } from '../../../../src/components-lib/live/utils/dispatch-live-error';
|
|
|
|
// @vitest-environment jsdom
|
|
it('should dispatch live error event', () => {
|
|
const element = document.createElement('div');
|
|
const handler = vi.fn();
|
|
element.addEventListener('advanced-camera-card:live:error', handler);
|
|
|
|
dispatchLiveErrorEvent(element);
|
|
expect(handler).toBeCalled();
|
|
});
|
|
|
|
it('should forward the reason as the event detail', () => {
|
|
const element = document.createElement('div');
|
|
const handler = vi.fn();
|
|
element.addEventListener('advanced-camera-card:live:error', handler);
|
|
|
|
dispatchLiveErrorEvent(element, 'unsupported');
|
|
expect(handler).toHaveBeenCalledWith(
|
|
expect.objectContaining({ detail: 'unsupported' }),
|
|
);
|
|
});
|