UNPKG

@kintone/dts-gen

Version:

Types for kintone js api and Types generating tools

78 lines 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const axios_utils_1 = require("./axios-utils"); describe("FormsClientImpl#constructor", () => { const baseUrl = "https://kintone.com"; const authToken = Buffer.from("username:password").toString("base64"); const assertConstructorWithArgs = (input, expectedInput) => { axios_utils_1.VisibleForTesting.newAxiosInstanceInternal = jest.fn(); axios_utils_1.AxiosUtils.newAxiosInstance(input); expect(axios_utils_1.VisibleForTesting.newAxiosInstanceInternal).toBeCalledWith(expectedInput); }; test("with plain settings", () => { const input = { baseUrl, username: "username", password: "password", proxy: null, basicAuthPassword: null, basicAuthUsername: null, }; const headers = { "X-Cybozu-Authorization": authToken, }; const expectedCalledWith = { headers, baseURL: baseUrl, proxy: undefined, }; assertConstructorWithArgs(input, expectedCalledWith); }); test("with proxy option", () => { const input = { baseUrl, username: "username", password: "password", proxy: "http://admin:password@localhost:1234", basicAuthPassword: null, basicAuthUsername: null, }; const headers = { "X-Cybozu-Authorization": authToken, }; const expectedCalledWith = { headers, baseURL: baseUrl, proxy: { host: "localhost", port: 1234, auth: { username: "admin", password: "password", }, }, }; assertConstructorWithArgs(input, expectedCalledWith); }); test("with basic auth", () => { const input = { baseUrl, username: "username", password: "password", proxy: null, basicAuthPassword: "basicUsername", basicAuthUsername: "basicPassword", }; const headers = { "X-Cybozu-Authorization": authToken, Authorization: "Basic YmFzaWNQYXNzd29yZDpiYXNpY1VzZXJuYW1l", }; const expectedCalledWith = { headers, baseURL: baseUrl, proxy: undefined, }; assertConstructorWithArgs(input, expectedCalledWith); }); }); //# sourceMappingURL=axios-utils.test.js.map