chore: Upgrade to Vitest 4 and regroup tests for performance (#2618)
This commit is contained in:
@@ -14,7 +14,7 @@ describe('MJPEGStreamSource', () => {
|
||||
const channel = new FakeStreamSourceChannel();
|
||||
const loadedCallback = vi.fn();
|
||||
const failedCallback = vi.fn();
|
||||
const showFrame = vi.fn<[Blob], Promise<void>>(() => Promise.resolve());
|
||||
const showFrame = vi.fn<(blob: Blob) => Promise<void>>(() => Promise.resolve());
|
||||
|
||||
const context: StreamSourceContext<ImageStreamTarget> = {
|
||||
target: { kind: 'image', showFrame },
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('MP4StreamSource', () => {
|
||||
const channel = new FakeStreamSourceChannel();
|
||||
const loadedCallback = vi.fn();
|
||||
const failedCallback = vi.fn();
|
||||
const showFrame = vi.fn<[Blob], Promise<void>>(() => Promise.resolve());
|
||||
const showFrame = vi.fn<(blob: Blob) => Promise<void>>(() => Promise.resolve());
|
||||
const context: StreamSourceContext<ImageStreamTarget> = {
|
||||
target: { kind: 'image', showFrame },
|
||||
channel,
|
||||
@@ -65,6 +65,7 @@ describe('MP4StreamSource', () => {
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should request the mp4 stream on start', () => {
|
||||
@@ -217,6 +218,12 @@ describe('MP4StreamSource', () => {
|
||||
callbacks: { loadedCallback: vi.fn(), failedCallback: vi.fn() },
|
||||
});
|
||||
|
||||
// This is the only test that reaches a real canvas element. jsdom does not
|
||||
// implement `getContext` and writes an error to the console when it is
|
||||
// called; the source treats a missing context as nothing to draw to avoid
|
||||
// console spam.
|
||||
vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue(null);
|
||||
|
||||
const createElement = vi.spyOn(document, 'createElement');
|
||||
source.start();
|
||||
channel.binaryCallback?.(frame());
|
||||
|
||||
Reference in New Issue
Block a user