chore: change type for adminSdkJson parameter

This commit is contained in:
2024-06-15 06:11:09 -04:00
parent fd61974740
commit a9e363e814
4 changed files with 27 additions and 8 deletions

View File

@@ -7,18 +7,33 @@ import { verifyFcmToken } from "./verifyFcmToken";
server.listen();
const FAKE_ADMIN_SDK_JSON = {
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",
};
describe("verifyFcmToken", () => {
it("valid token, returns true", async () => {
const token =
"7v8sy43aq0re4r8xe7rmr0cn1fsmh6phehnfla2pa73z899zmhyarivmkt4sj6pyv0py43u6p2sim6wz2vg9ypjp9rug1keoth7f6ll3gdvas4q020u3ah51r6bjgn51j6bd92ztmtof3ljpcm8q31njvndy65enm68";
const res = await verifyFcmToken(token, '{"clientEmail": "test@test.com"}');
const res = await verifyFcmToken(token, FAKE_ADMIN_SDK_JSON);
expect(res).toBeTrue();
});
it("invalid token, returns false", async () => {
const token = "abc123";
const res = await verifyFcmToken(token, '{"clientEmail": "test@test.com"}');
const res = await verifyFcmToken(token, FAKE_ADMIN_SDK_JSON);
expect(res).toBeFalse();
});