test: mock Cloudflare worker environment

Adds a mock for cloudflare workers to enable testing
of code that relies on the cloudflare workers environment.
This commit is contained in:
2025-08-10 19:52:54 -04:00
parent 6de8c594b7
commit 26037d592e
2 changed files with 25 additions and 0 deletions

24
src/mocks/cloudflare.ts Normal file
View File

@@ -0,0 +1,24 @@
import { mock } from "bun:test";
mock.module("cloudflare:workers", () => ({
env: {
ADMIN_SDK_JSON: JSON.stringify({
type: "service_account",
projectId: "test-26g38",
privateKeyId: "privateKeyId",
privateKey: "privateKey",
clientEmail: "test@test.com",
clientID: "clientId",
authURI: "https://accounts.google.com/o/oauth2/auth",
tokenURI: "https://oauth2.googleapis.com/token",
authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs",
clientX509CertUrl:
"https://www.googleapis.com/robot/v1/metadata/x509/test%40test.com",
universeDomain: "aniplay.com",
}),
ANIWATCH_URL: "https://aniwatch.to",
CONSUMET_URL: "https://api.consumet.org",
ANILIST_URL: "https://graphql.anilist.co",
GOOGLE_AUTH_URL: "https://www.googleapis.com/oauth2/v4/token",
},
}));