mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
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:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user