UNPKG

@kintone/dts-gen

Version:

Types for kintone js api and Types generating tools

171 lines 6.24 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.DTSGenApiTest = void 0; const assert = __importStar(require("assert")); const assertKintoneBuiltinFunctions = () => { assertFunctionExistInKintoneTopLevel(); assertFunctionExistInKintonePromise(); assertFunctionExistInKintoneEvent(); assertFunctionExistInKintoneAPI(); assertFunctionExistInKintoneProxy(); assetFunctionExistInKintoneApp(); assertFunctionExistInKintoneAppRecord(); assertFunctionExistInKintoneMobileApp(); assertFunctionExistInKintoneMobileAppRecord(); assertPortalAPI(); assertSpaceAPI(); }; const assertFunction = (ref) => { assert.ok(ref); assert.ok(typeof ref === "function"); }; exports.DTSGenApiTest = { assertKintoneBuiltinFunctions, }; const assertFunctionExistInKintoneTopLevel = () => { assertFunction(kintone.getRequestToken); assertFunction(kintone.getLoginUser); assertFunction(kintone.getUiVersion); }; const assertFunctionExistInKintonePromise = () => { assertFunction(kintone.Promise); assertFunction(kintone.Promise.all); assertFunction(kintone.Promise.resolve); assertFunction(kintone.Promise.reject); // kintone.api.url assert.ok(kintone.api.url("/k/v1/records").endsWith("/k/v1/records.json")); // only to check to compile success kintone.api.url("/k/v1/records", true); const okPromise = new kintone.Promise((resolve) => resolve(1)); assert.ok(okPromise); okPromise .then((resolved) => { assert.ok(resolved === 1); }) .catch(() => { assert.fail("should not be called"); }); const ngPromise = new kintone.Promise((_, reject) => reject(1)); ngPromise .then(() => { assert.fail("should not be called"); }) .catch((rejected) => assert.ok(rejected === 1)); kintone.Promise.resolve(1) .then((resolved) => assert.ok(resolved === 1)) .catch(() => assert.fail("should not be called")); kintone.Promise.reject("reject") .then(() => assert.fail("should not be called")) .catch((reject) => assert.ok(reject === "reject")); kintone.Promise.all([ kintone.Promise.resolve(1), kintone.Promise.resolve(2), kintone.Promise.resolve(3), ]).then((resolved) => { assert.ok(resolved.length === 3); assert.ok(resolved[0] === 1); assert.ok(resolved[1] === 2); assert.ok(resolved[2] === 3); }); }; const assertFunctionExistInKintoneEvent = () => { const e = kintone.events; assertFunction(e.on); assertFunction(e.off); }; const assertFunctionExistInKintoneAPI = () => { const a = kintone.api; assertFunction(a); assertFunction(a.url); assertFunction(a.urlForGet); assertFunction(a.getConcurrencyLimit); }; const assertFunctionExistInKintoneProxy = () => { const p = kintone.proxy; assertFunction(p); assertFunction(p.upload); }; const assetFunctionExistInKintoneApp = () => { const app = kintone.app; assertFunction(app.getFieldElements); assertFunction(app.getHeaderMenuSpaceElement); assertFunction(app.getHeaderSpaceElement); assertFunction(app.getId); assertFunction(app.getLookupTargetAppId); assertFunction(app.getQuery); assertFunction(app.getQueryCondition); assertFunction(app.getRelatedRecordsTargetAppId); }; const assertFunctionExistInKintoneAppRecord = () => { const r = kintone.app.record; assertFunction(r.get); assertFunction(r.getHeaderMenuSpaceElement); assertFunction(r.getFieldElement); assertFunction(r.getId); assertFunction(r.getSpaceElement); assertFunction(r.set); assertFunction(r.setFieldShown); assertFunction(r.setGroupFieldOpen); }; const assertFunctionExistInKintoneMobileApp = () => { const ma = kintone.mobile.app; assertFunction(ma.getFieldElements); assertFunction(ma.getHeaderSpaceElement); assertFunction(ma.getId); assertFunction(ma.getLookupTargetAppId); assertFunction(ma.getQuery); assertFunction(ma.getQueryCondition); assertFunction(ma.getRelatedRecordsTargetAppId); }; const assertFunctionExistInKintoneMobileAppRecord = () => { const mr = kintone.mobile.app.record; assertFunction(mr.get); assertFunction(mr.getId); assertFunction(mr.getFieldElement); assertFunction(mr.getSpaceElement); assertFunction(mr.set); assertFunction(mr.setFieldShown); assertFunction(mr.setGroupFieldOpen); }; const assertPortalAPI = () => { assertFunction(kintone.portal.getContentSpaceElement); assertFunction(kintone.mobile.portal.getContentSpaceElement); }; const assertSpaceAPI = () => { assertFunction(kintone.space.portal.getContentSpaceElement); assertFunction(kintone.mobile.space.portal.getContentSpaceElement); }; //# sourceMappingURL=dts-gen-api-test.js.map