saleor-app-sdk-REDIS_APL/src/handlers/next/create-manifest-handler.test.ts
Lukasz Ostrowski 0352356fd3
Add Handler factories (#61)
* Add createManifestHandler

* Add register handler factory

* Add docs to handlers factory

* Improve tsup configuration (select entry points)

* Reexport symbols from index

* Improve tests
2022-09-21 11:25:01 +02:00

41 lines
1.1 KiB
TypeScript

import { createMocks } from "node-mocks-http";
import { describe, expect, it } from "vitest";
import { AppManifest } from "../../types";
import { createManifestHandler } from "./create-manifest-handler";
describe("createManifestHandler", () => {
it("Creates a handler that responds with Manifest", async () => {
const { res, req } = createMocks({
headers: {
host: "some-saleor-host.cloud",
"x-forwarded-proto": "https",
},
method: "GET",
});
const handler = createManifestHandler({
manifestFactory(context: { appBaseUrl: string }): AppManifest {
return {
name: "Mock name",
tokenTargetUrl: `${context.appBaseUrl}/api/register`,
appUrl: context.appBaseUrl,
permissions: [],
id: "app-id",
version: "1",
};
},
});
await handler(req, res);
expect(res._getData()).toEqual({
appUrl: "https://some-saleor-host.cloud",
id: "app-id",
name: "Mock name",
permissions: [],
tokenTargetUrl: "https://some-saleor-host.cloud/api/register",
version: "1",
});
});
});