mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-10 21:55:19 +00:00
Cover the stopProcessor failure path and trackProcessorSync
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GSB8Qb89KDoTNRV83dWJHa
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
2e5b5cb186
commit
b284bb00c0
@@ -12,7 +12,9 @@ import {
|
|||||||
type ProcessorWrapper,
|
type ProcessorWrapper,
|
||||||
} from "@livekit/track-processors";
|
} from "@livekit/track-processors";
|
||||||
|
|
||||||
import { applyProcessor } from "./TrackProcessorContext";
|
import { applyProcessor, trackProcessorSync } from "./TrackProcessorContext";
|
||||||
|
import { constant } from "../state/Behavior";
|
||||||
|
import { testScope } from "../utils/test";
|
||||||
|
|
||||||
const processor = {} as ProcessorWrapper<BackgroundOptions>;
|
const processor = {} as ProcessorWrapper<BackgroundOptions>;
|
||||||
|
|
||||||
@@ -59,4 +61,27 @@ describe("applyProcessor", () => {
|
|||||||
applyProcessor(track, undefined);
|
applyProcessor(track, undefined);
|
||||||
expect(track.stopProcessor).toHaveBeenCalled();
|
expect(track.stopProcessor).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not surface a rejected stopProcessor", async () => {
|
||||||
|
const track = mockTrack("live", processor);
|
||||||
|
vi.mocked(track.stopProcessor).mockRejectedValue(new Error("nope"));
|
||||||
|
const unhandled = vi.fn();
|
||||||
|
process.on("unhandledRejection", unhandled);
|
||||||
|
applyProcessor(track, undefined);
|
||||||
|
await new Promise((r) => setTimeout(r, 0));
|
||||||
|
process.off("unhandledRejection", unhandled);
|
||||||
|
expect(unhandled).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("trackProcessorSync", () => {
|
||||||
|
it("applies the processor to the current track", () => {
|
||||||
|
const track = mockTrack("live");
|
||||||
|
trackProcessorSync(
|
||||||
|
testScope(),
|
||||||
|
constant(track),
|
||||||
|
constant({ supported: true, processor }),
|
||||||
|
);
|
||||||
|
expect(track.setProcessor).toHaveBeenCalledWith(processor);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user