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:
@@ -3,4 +3,5 @@ preload = [
|
|||||||
"./testSetup.ts",
|
"./testSetup.ts",
|
||||||
"./src/mocks/consumet.ts",
|
"./src/mocks/consumet.ts",
|
||||||
"./src/mocks/getGoogleAuthToken.ts",
|
"./src/mocks/getGoogleAuthToken.ts",
|
||||||
|
"./src/mocks/cloudflare.ts",
|
||||||
]
|
]
|
||||||
|
|||||||
24
src/mocks/cloudflare.ts
Normal file
24
src/mocks/cloudflare.ts
Normal 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",
|
||||||
|
},
|
||||||
|
}));
|
||||||
Reference in New Issue
Block a user