chore: update src/lib/integrations/webhooks.test.ts
swadhinbiswas committed 8 months ago
9968b3b
1 parent 8fa6908
commit 9968b3b
1 file changed
+3 -4
Showing 1 changed file+3-4
▼src/lib/integrations/webhooks.test.ts
+3-4
| @@ -1,11 +1,10 @@ | ||
1 | -// @ts-ignore | |
2 | -import { describe, it, expect, mock, beforeEach, afterEach } from "bun:test"; | |
1 | +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; | |
3 | 2 | import { sendDiscordMessage, createPREmbed } from "./discord"; |
4 | 3 | import { sendTeamsMessage, createPRCard } from "./teams"; |
5 | 4 | |
6 | 5 | // Mock fetch globally |
7 | 6 | const originalFetch = global.fetch; |
8 | -const mockFetch = mock((url: string | Request | URL, init?: RequestInit) => { | |
7 | +const mockFetch = vi.fn((url: string | Request | URL, init?: RequestInit) => { | |
9 | 8 | return Promise.resolve(new Response("OK", { status: 200 })); |
10 | 9 | }); |
11 | 10 | |
| @@ -45,7 +44,7 @@ describe("Webhook Integrations", () => { | ||
45 | 44 | }); |
46 | 45 | |
47 | 46 | it("should handle failures gracefully", async () => { |
48 | - global.fetch = mock(() => Promise.resolve(new Response("Error", { status: 500 }))); | |
47 | + global.fetch = vi.fn(() => Promise.resolve(new Response("Error", { status: 500 }))); | |
49 | 48 | |
50 | 49 | const success = await sendDiscordMessage("https://discord.com/api/webhooks/xyz", {}); |
51 | 50 | expect(success).toBe(false); |
52 | 51 | |