fix: resolve Stryker TypeScript checker errors in test files

Add non-null assertions to mock .calls[0] access in notifications tests
and mockListen implementation reference in ws tests. Required by
Stryker's stricter TS checker vs vitest runtime.
This commit is contained in:
jevb
2026-04-01 14:59:04 +02:00
parent a1d63ec840
commit bdf41f8659
2 changed files with 7 additions and 7 deletions
@@ -571,7 +571,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.title).toBe(`${"U".repeat(68)} in #general`);
expect(call.title.length).toBe(80);
// Should NOT end with "..."
@@ -598,7 +598,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.title.endsWith("...")).toBe(true);
// Truncated to 80 chars + "..." = 83
expect(call.title.length).toBe(83);
@@ -622,7 +622,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.body).toBe("B".repeat(100));
expect(call.body.endsWith("...")).toBe(false);
});
@@ -645,7 +645,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.body.endsWith("...")).toBe(true);
expect(call.body.length).toBe(103); // 100 + "..."
});
@@ -667,7 +667,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.title).toBe("EvilUser in #general");
expect(call.body).toBe("HelloWorld!");
});
@@ -691,7 +691,7 @@ describe("notifyIncomingMessage", () => {
notifyIncomingMessage(payload);
await vi.waitFor(() => {
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0][0];
const call = (sendNotification as ReturnType<typeof vi.fn>).mock.calls[0]![0];
expect(call.body).toBe("C".repeat(100));
expect(call.body.endsWith("...")).toBe(false);
});
+1 -1
View File
@@ -2541,7 +2541,7 @@ describe("cleanupEventListeners edge cases", () => {
afterEach(() => {
client.disconnect();
// Restore the original mockListen implementation so later tests work
mockListen.mockImplementation(originalMockListenImpl);
mockListen.mockImplementation(originalMockListenImpl!);
vi.useRealTimers();
});