fix(test): widen capturedHandler cast to resolve TS2349 never narrowing (FAR-40)
TypeScript CFA does not trace the assignment inside the vi.spyOn mockImplementation callback, so it narrows capturedHandler to null at the if-check, making the body unreachable (never). Cast at the call site breaks the false narrowing without changing runtime behaviour. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -357,7 +357,7 @@ describe("execute — SIGTERM handler", () => {
|
|||||||
if (capturedHandler) {
|
if (capturedHandler) {
|
||||||
const batchApi = vi.mocked(getBatchApi)();
|
const batchApi = vi.mocked(getBatchApi)();
|
||||||
// Fire the handler and verify it deletes the job that was just created.
|
// Fire the handler and verify it deletes the job that was just created.
|
||||||
try { capturedHandler(); } catch { /* swallow process.exit throw */ }
|
try { (capturedHandler as () => void)(); } catch { /* swallow process.exit throw */ }
|
||||||
await new Promise((r) => setTimeout(r, 50)); // let async handler tick
|
await new Promise((r) => setTimeout(r, 50)); // let async handler tick
|
||||||
expect(batchApi.deleteNamespacedJob).toHaveBeenCalled();
|
expect(batchApi.deleteNamespacedJob).toHaveBeenCalled();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user