feat: Surface the provider's error cause in the media_unavailable notification (#2599)
- Closes: #2592
This commit is contained in:
@@ -3,22 +3,27 @@ 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', () => {
|
||||
it('should dispatch live error event with an empty error when none is given', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('advanced-camera-card:live:error', handler);
|
||||
|
||||
dispatchLiveErrorEvent(element);
|
||||
expect(handler).toBeCalled();
|
||||
expect(handler).toHaveBeenCalledWith(expect.objectContaining({ detail: {} }));
|
||||
});
|
||||
|
||||
it('should forward the reason as the event detail', () => {
|
||||
it('should forward the reason and detail as the event detail', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('advanced-camera-card:live:error', handler);
|
||||
|
||||
dispatchLiveErrorEvent(element, 'unsupported');
|
||||
dispatchLiveErrorEvent(element, {
|
||||
reason: 'unsupported',
|
||||
detail: 'Codec not supported',
|
||||
});
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ detail: 'unsupported' }),
|
||||
expect.objectContaining({
|
||||
detail: { reason: 'unsupported', detail: 'Codec not supported' },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user