Open
Description
I'm trying to test authorization in my function, but auth.token
object needed lots of properties which I don't need
import { beforeEach, describe, expect, it } from "vitest"
import { updateService as fn } from "./update"
import { WrappedV2CallableFunction, wrapV2 } from "firebase-functions-test/lib/v2"
import { defaultService } from "@features/service/data/service"
import { CallableRequest } from "firebase-functions/lib/common/providers/https"
describe("update service", () => {
let updateService: WrappedV2CallableFunction<any>
beforeEach(() => {
updateService = wrapV2(fn)
})
it("should reject unauthorized users", async () => {
const request: CallableRequest = {
acceptsStreaming: false,
rawRequest : {} as any,
data : defaultService(),
auth : {
uid : "test",
token: {
// TOO much properties
}
}
}
await expect(updateService(request)).rejects.toThrowError("Login")
})
})
I also don't need acceptsStreaming
and rawRequest
, but that has been talked about in #257