UNPKG

@line/bot-sdk

Version:
66 lines (65 loc) 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("../../api"); const msw_1 = require("msw"); const node_1 = require("msw/node"); const assert_1 = require("assert"); const pkg = require("../../../../package.json"); const channel_access_token = "test_channel_access_token"; describe("LineModuleAttachClient", () => { const server = (0, node_1.setupServer)(); before(() => { server.listen(); }); after(() => { server.close(); }); afterEach(() => { server.resetHandlers(); }); const client = new api_1.LineModuleAttachClient({ channelAccessToken: channel_access_token, }); it("attachModule", async () => { let requestCount = 0; const endpoint = "https://manager.line.biz/module/auth/v1/token" .replace("{grantType}", "DUMMY") // string .replace("{code}", "DUMMY") // string .replace("{redirectUri}", "DUMMY") // string .replace("{codeVerifier}", "DUMMY") // string .replace("{clientId}", "DUMMY") // string .replace("{clientSecret}", "DUMMY") // string .replace("{region}", "DUMMY") // string .replace("{basicSearchId}", "DUMMY") // string .replace("{scope}", "DUMMY") // string .replace("{brandType}", "DUMMY"); // string server.use(msw_1.http.post(endpoint, ({ request, params, cookies }) => { requestCount++; (0, assert_1.equal)(request.headers.get("Authorization"), `Bearer ${channel_access_token}`); (0, assert_1.equal)(request.headers.get("User-Agent"), `${pkg.name}/${pkg.version}`); return msw_1.HttpResponse.json({}); })); const res = await client.attachModule( // grantType: string "DUMMY", // grantType(string) // code: string "DUMMY", // code(string) // redirectUri: string "DUMMY", // redirectUri(string) // codeVerifier: string "DUMMY", // codeVerifier(string) // clientId: string "DUMMY", // clientId(string) // clientSecret: string "DUMMY", // clientSecret(string) // region: string "DUMMY", // region(string) // basicSearchId: string "DUMMY", // basicSearchId(string) // scope: string "DUMMY", // scope(string) // brandType: string "DUMMY"); (0, assert_1.equal)(requestCount, 1); }); });