UNPKG

@kintone/customize-uploader

Version:
83 lines 3.76 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const assert_1 = __importDefault(require("assert")); const index_1 = require("../index"); const MockKintoneApiClient_1 = __importDefault(require("./MockKintoneApiClient")); describe("index", () => { describe("upload", () => { let kintoneApiClient; let manifest; let status; let options; beforeEach(() => { kintoneApiClient = new MockKintoneApiClient_1.default("kintone", "hogehoge", "oAuthToken", "basicAuthUser", "basicAuthPass", "https://example.com", { proxy: "", guestSpaceId: 0, }); manifest = { app: "1", scope: "ALL", desktop: { js: [ "src/commands/__tests__/fixtures/a.js", "src/commands/__tests__/fixtures/b.js", "https://js.cybozu.com/jquery/3.3.1/jquery.min.js", ], css: ["src/commands/__tests__/fixtures/a.css"], }, mobile: { js: ["src/commands/__tests__/fixtures/c.js"], css: ["src/commands/__tests__/fixtures/d.css"], }, }; status = { retryCount: 0, updateBody: null, updated: false, }; options = { lang: "en", proxy: "", guestSpaceId: 0, }; }); it("should succeed the uploading", () => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, index_1.upload)(kintoneApiClient, manifest, status, options); assert_1.default.ok(true, "the upload has been successful"); } catch (e) { assert_1.default.fail(e); } })); it("should call kintone APIs by the right order", () => __awaiter(void 0, void 0, void 0, function* () { yield (0, index_1.upload)(kintoneApiClient, manifest, status, options); assert_1.default.deepStrictEqual(kintoneApiClient.logs.map(({ method, path }) => ({ method, path, })), [ { method: "POST", path: "/k/v1/file.json" }, { method: "POST", path: "/k/v1/file.json" }, { method: "POST", path: "/k/v1/file.json" }, { method: "POST", path: "/k/v1/file.json" }, { method: "POST", path: "/k/v1/file.json" }, { method: "PUT", path: "/k/v1/preview/app/customize.json" }, { method: "POST", path: "/k/v1/preview/app/deploy.json" }, { method: "GET", path: "/k/v1/preview/app/deploy.json" }, ]); })); }); }); //# sourceMappingURL=index.test.js.map