feat: create lib function to verify FCM token

This commit is contained in:
2024-06-15 05:47:26 -04:00
parent 20ca88fda9
commit 7675867549
10 changed files with 219 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
import { describe, expect, it } from "bun:test";
import { server } from "~/mocks";
import "~/mocks/gToken";
import { verifyFcmToken } from "./verifyFcmToken";
server.listen();
describe("verifyFcmToken", () => {
it("valid token, returns true", async () => {
const token =
"7v8sy43aq0re4r8xe7rmr0cn1fsmh6phehnfla2pa73z899zmhyarivmkt4sj6pyv0py43u6p2sim6wz2vg9ypjp9rug1keoth7f6ll3gdvas4q020u3ah51r6bjgn51j6bd92ztmtof3ljpcm8q31njvndy65enm68";
const res = await verifyFcmToken(token, '{"clientEmail": "test@test.com"}');
expect(res).toBeTrue();
});
it("invalid token, returns false", async () => {
const token = "abc123";
const res = await verifyFcmToken(token, '{"clientEmail": "test@test.com"}');
expect(res).toBeFalse();
});
});