UNPKG

@kintone/dts-gen

Version:

Types for kintone js api and Types generating tools

139 lines 5.39 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 (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DTSGenApiTest = void 0; const assert = __importStar(require("assert")); const assertKintoneBuiltinFunctions = () => { // assert function exists in kintone top-level assertFunction(kintone.getRequestToken); assertFunction(kintone.getLoginUser); assertFunction(kintone.getUiVersion); // assert function exists in kintone.Promise 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); }); // assert function exists in kintone.events const e = kintone.events; assertFunction(e.on); assertFunction(e.off); // assert function exists in kintone.api const a = kintone.api; assertFunction(a); assertFunction(a.url); assertFunction(a.urlForGet); assertFunction(a.getConcurrencyLimit); // assert function exists in kintone.proxy const p = kintone.proxy; assertFunction(p); assertFunction(p.upload); // assert function exists in kintone.app 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); // assert function exists in kintone.app.record 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); // assert function exists in kintone.mobile.app 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); // assert function exists in kintone.mobile.app.record 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); // Portal API assertFunction(kintone.portal.getContentSpaceElement); assertFunction(kintone.mobile.portal.getContentSpaceElement); // Space API assertFunction(kintone.space.portal.getContentSpaceElement); assertFunction(kintone.mobile.space.portal.getContentSpaceElement); }; const assertFunction = (ref) => { assert.ok(ref); assert.ok(typeof ref === "function"); }; exports.DTSGenApiTest = { assertKintoneBuiltinFunctions, }; //# sourceMappingURL=dts-gen-api-test.js.map