From 5782d2e286fa17b1214928587e74cffb70081ae7 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Thu, 21 Mar 2024 15:15:25 +0200 Subject: [PATCH] fix: transpile and test --- .gitignore | 3 +- dist/entity/mixins/context.d.ts | 2 +- dist/entity/mixins/context.js | 4 +- dist/entity/mixins/runtime_items.d.ts | 4 +- dist/entity/mixins/runtime_items.js | 6 +- dist/entity/other.d.ts | 6 +- dist/esse/types.d.ts | 1 - dist/esse/types.js | 30 --- dist/utils/object.js | 2 +- package-lock.json | 24 +- src/js/entity/mixins/context.ts | 5 +- src/js/entity/mixins/runtime_items.ts | 7 +- tests/js/context.tests.d.ts | 1 - tests/js/context.tests.js | 81 ------- tests/js/enums.d.ts | 9 - tests/js/enums.js | 63 ------ tests/js/fixtures/rjsf_schemas.d.ts | 230 -------------------- tests/js/fixtures/yaml_include_tag.yml | 2 +- tests/js/fixtures/yaml_parameter_tag.yml | 6 +- tests/js/fixtures/yaml_readFile_tag.yml | 2 +- tests/js/in_memory.tests.d.ts | 1 - tests/js/in_memory.tests.js | 88 -------- tests/js/mixin.flowchart.tests.d.ts | 1 - tests/js/mixin.flowchart.tests.js | 87 -------- tests/js/provider.tests.d.ts | 1 - tests/js/provider.tests.js | 22 -- tests/js/utils.d.ts | 4 - tests/js/utils.js | 14 -- tests/js/utils/class.tests.d.ts | 1 - tests/js/utils/class.tests.js | 98 --------- tests/js/utils/file.tests.d.ts | 1 - tests/js/utils/file.tests.js | 11 - tests/js/utils/filter.tests.d.ts | 1 - tests/js/utils/filter.tests.js | 94 -------- tests/js/utils/object.tests.d.ts | 1 - tests/js/utils/object.tests.js | 91 -------- tests/js/utils/schemas.tests.d.ts | 1 - tests/js/utils/schemas.tests.js | 121 ---------- tests/js/utils/str.tests.d.ts | 1 - tests/js/utils/str.tests.js | 70 ------ tests/js/utils/tree.tests.d.ts | 1 - tests/js/utils/tree.tests.js | 34 --- tests/js/utils/utils.tests.d.ts | 1 - tests/js/utils/utils.tests.js | 34 --- tests/js/utils/yaml.combine.tests.d.ts | 1 - tests/js/utils/yaml.combine.tests.js | 122 ----------- tests/js/utils/yaml.concatString.tests.d.ts | 1 - tests/js/utils/yaml.concatString.tests.js | 31 --- tests/js/utils/yaml.esse.tests.d.ts | 1 - tests/js/utils/yaml.esse.tests.js | 58 ----- tests/js/utils/yaml.flatten.tests.d.ts | 1 - tests/js/utils/yaml.flatten.tests.js | 21 -- tests/js/utils/yaml.include.tests.d.ts | 1 - tests/js/utils/yaml.include.tests.js | 33 --- tests/js/utils/yaml.include.tests.ts | 1 - tests/js/utils/yaml.listToString.tests.d.ts | 1 - tests/js/utils/yaml.listToString.tests.js | 33 --- tests/js/utils/yaml.parameter.tests.d.ts | 1 - tests/js/utils/yaml.parameter.tests.js | 61 ------ tests/js/utils/yaml.readFile.tests.d.ts | 1 - tests/js/utils/yaml.readFile.tests.js | 22 -- tsconfig.json | 40 ++-- 62 files changed, 46 insertions(+), 1651 deletions(-) delete mode 100644 dist/esse/types.d.ts delete mode 100644 dist/esse/types.js delete mode 100644 tests/js/context.tests.d.ts delete mode 100644 tests/js/context.tests.js delete mode 100644 tests/js/enums.d.ts delete mode 100644 tests/js/enums.js delete mode 100644 tests/js/fixtures/rjsf_schemas.d.ts delete mode 100644 tests/js/in_memory.tests.d.ts delete mode 100644 tests/js/in_memory.tests.js delete mode 100644 tests/js/mixin.flowchart.tests.d.ts delete mode 100644 tests/js/mixin.flowchart.tests.js delete mode 100644 tests/js/provider.tests.d.ts delete mode 100644 tests/js/provider.tests.js delete mode 100644 tests/js/utils.d.ts delete mode 100644 tests/js/utils.js delete mode 100644 tests/js/utils/class.tests.d.ts delete mode 100644 tests/js/utils/class.tests.js delete mode 100644 tests/js/utils/file.tests.d.ts delete mode 100644 tests/js/utils/file.tests.js delete mode 100644 tests/js/utils/filter.tests.d.ts delete mode 100644 tests/js/utils/filter.tests.js delete mode 100644 tests/js/utils/object.tests.d.ts delete mode 100644 tests/js/utils/object.tests.js delete mode 100644 tests/js/utils/schemas.tests.d.ts delete mode 100644 tests/js/utils/schemas.tests.js delete mode 100644 tests/js/utils/str.tests.d.ts delete mode 100644 tests/js/utils/str.tests.js delete mode 100644 tests/js/utils/tree.tests.d.ts delete mode 100644 tests/js/utils/tree.tests.js delete mode 100644 tests/js/utils/utils.tests.d.ts delete mode 100644 tests/js/utils/utils.tests.js delete mode 100644 tests/js/utils/yaml.combine.tests.d.ts delete mode 100644 tests/js/utils/yaml.combine.tests.js delete mode 100644 tests/js/utils/yaml.concatString.tests.d.ts delete mode 100644 tests/js/utils/yaml.concatString.tests.js delete mode 100644 tests/js/utils/yaml.esse.tests.d.ts delete mode 100644 tests/js/utils/yaml.esse.tests.js delete mode 100644 tests/js/utils/yaml.flatten.tests.d.ts delete mode 100644 tests/js/utils/yaml.flatten.tests.js delete mode 100644 tests/js/utils/yaml.include.tests.d.ts delete mode 100644 tests/js/utils/yaml.include.tests.js delete mode 100644 tests/js/utils/yaml.listToString.tests.d.ts delete mode 100644 tests/js/utils/yaml.listToString.tests.js delete mode 100644 tests/js/utils/yaml.parameter.tests.d.ts delete mode 100644 tests/js/utils/yaml.parameter.tests.js delete mode 100644 tests/js/utils/yaml.readFile.tests.d.ts delete mode 100644 tests/js/utils/yaml.readFile.tests.js diff --git a/.gitignore b/.gitignore index 15490f1f..ef888273 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ __pycache__/ .Python build/ develop-eggs/ -dist/ downloads/ eggs/ .eggs/ @@ -173,3 +172,5 @@ node_modules/ ########### GENERAL ############# *.DS_Store + +tsconfig.tsbuildinfo diff --git a/dist/entity/mixins/context.d.ts b/dist/entity/mixins/context.d.ts index c724534e..a914a46c 100644 --- a/dist/entity/mixins/context.d.ts +++ b/dist/entity/mixins/context.d.ts @@ -10,7 +10,7 @@ export declare function ContextAndRenderFieldsMixin(name: string, defaultValue: T_1): T_1; prop(name: string): T_2 | undefined; diff --git a/dist/entity/mixins/context.js b/dist/entity/mixins/context.js index c444b3da..4f5a4468 100644 --- a/dist/entity/mixins/context.js +++ b/dist/entity/mixins/context.js @@ -38,8 +38,8 @@ function ContextAndRenderFieldsMixin(superclass) { return { ...this.getPersistentContext(), ...this.context }; } // override in subclasses - // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars - render(context = this.context) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + render(_context = this.context) { throw new Error("RenderInitMixin: render not implemented in derived class"); } }; diff --git a/dist/entity/mixins/runtime_items.d.ts b/dist/entity/mixins/runtime_items.d.ts index 8e0b6233..9cd54f7d 100644 --- a/dist/entity/mixins/runtime_items.d.ts +++ b/dist/entity/mixins/runtime_items.d.ts @@ -55,11 +55,9 @@ export declare function RuntimeItemsUILogicMixin(name: string, defaultValue: T): T; prop(name: string): T_1 | undefined; @@ -527,7 +527,7 @@ export declare const NamedDefaultableRepetitionRuntimeItemsImportantSettingsCont getCombinedContext(): { [x: string]: unknown; }; - render(context?: import("./in_memory").AnyObject): void; + render(_context?: import("./in_memory").AnyObject): void; _json: import("./in_memory").AnyObject; prop(name: string, defaultValue: T): T; prop(name: string): T_1 | undefined; @@ -606,7 +606,7 @@ export declare const NamedDefaultableRepetitionRuntimeItemsImportantSettingsCont _json: import("./mixins/runtime_items").RuntimeItemsUILogicJSON; getDefaultsByKey(key: import("./mixins/runtime_items").ItemKey): import("@mat3ra/esse/lib/js/types").NameResultSchema[]; setRuntimeItemsToDefaultValues(): void; - _initRuntimeItems(keys: import("./mixins/runtime_items").ItemKey[], config: object): void; + _initRuntimeItems(keys: import("./mixins/runtime_items").ItemKey[], _config: object): void; _addRuntimeItem(key: import("./mixins/runtime_items").ItemKey | undefined, config: import("@mat3ra/esse/lib/js/types").RuntimeItemSchema): void; _removeRuntimeItem(key: import("./mixins/runtime_items").ItemKey | undefined, config: import("@mat3ra/esse/lib/js/types").RuntimeItemSchema): void; _removeRuntimeItemByName(key: import("./mixins/runtime_items").ItemKey, name: string): void; diff --git a/dist/esse/types.d.ts b/dist/esse/types.d.ts deleted file mode 100644 index e975cebe..00000000 --- a/dist/esse/types.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "@mat3ra/esse/lib/js/types"; diff --git a/dist/esse/types.js b/dist/esse/types.js deleted file mode 100644 index 15acda9c..00000000 --- a/dist/esse/types.js +++ /dev/null @@ -1,30 +0,0 @@ -"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 __exportStar = - (this && this.__exportStar) || - function (m, exports) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) - __createBinding(exports, m, p); - }; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("@mat3ra/esse/lib/js/types"), exports); diff --git a/dist/utils/object.js b/dist/utils/object.js index 8fc6ef9b..5f4da0c3 100644 --- a/dist/utils/object.js +++ b/dist/utils/object.js @@ -50,7 +50,7 @@ exports.getOneMatchFromObject = getOneMatchFromObject; */ function convertKeysToCamelCaseForObject(obj) { const newObj = (0, clone_1.deepClone)(obj); - return (0, mapKeys_1.default)(newObj, (v, k) => (0, camelCase_1.default)(k)); + return (0, mapKeys_1.default)(newObj, (_v, k) => (0, camelCase_1.default)(k)); } exports.convertKeysToCamelCaseForObject = convertKeysToCamelCaseForObject; function renameKeysForObject( diff --git a/package-lock.json b/package-lock.json index 055036a6..b3440475 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5621,7 +5621,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -5707,13 +5707,13 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -5972,7 +5972,7 @@ "release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", "dev": true, "requires": { "es6-error": "^4.0.1" @@ -5981,7 +5981,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-from-string": { @@ -6136,7 +6136,7 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, "set-function-length": { @@ -6261,7 +6261,7 @@ "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", "dev": true }, "source-map-support": { @@ -6419,7 +6419,7 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true }, "strip-final-newline": { @@ -6496,7 +6496,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "thenify": { @@ -6520,7 +6520,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "timers-ext": { @@ -6541,7 +6541,7 @@ "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "dev": true }, "to-regex-range": { @@ -6956,7 +6956,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "write-file-atomic": { diff --git a/src/js/entity/mixins/context.ts b/src/js/entity/mixins/context.ts index ec51c048..f0b97ee5 100644 --- a/src/js/entity/mixins/context.ts +++ b/src/js/entity/mixins/context.ts @@ -49,9 +49,8 @@ export function ContextAndRenderFieldsMixin } // override in subclasses - // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars - // @ts-ignore - render(context = this.context) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + render(_context = this.context) { throw new Error("RenderInitMixin: render not implemented in derived class"); } }; diff --git a/src/js/entity/mixins/runtime_items.ts b/src/js/entity/mixins/runtime_items.ts index 5af340bc..81b19297 100644 --- a/src/js/entity/mixins/runtime_items.ts +++ b/src/js/entity/mixins/runtime_items.ts @@ -107,13 +107,10 @@ export function RuntimeItemsUILogicMixin(su /** * @summary Must pass config for subclasses to override and use initialization logic - * @param keys - * @param config * @private */ - // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars - // @ts-ignore - _initRuntimeItems(keys: ItemKey[], config: object) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _initRuntimeItems(keys: ItemKey[], _config: object) { // keeping this separate from constructor so that it can be overridden in mixing (eg. in `ExecutionUnit`) // eslint-disable-next-line @typescript-eslint/no-this-alias const me = this; diff --git a/tests/js/context.tests.d.ts b/tests/js/context.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/context.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/context.tests.js b/tests/js/context.tests.js deleted file mode 100644 index 0405ab4d..00000000 --- a/tests/js/context.tests.js +++ /dev/null @@ -1,81 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const context_1 = require("../../src/js/context"); - -class MockMaterial { - static createDefault() { - return "defaultMockMaterial"; - } -} -class SpecificMockMaterial { - static createDefault() { - return "defaultSpecificMockMaterial"; - } -} -class MockApplication { - static createDefault() { - return "defaultMockApplication"; - } -} -class SpecificMockApplication { - static createDefault() { - return "defaultSpecificMockApplication"; - } -} -class ProviderEntity extends (0, context_1.MaterialContextMixin)( - (0, context_1.ApplicationContextMixin)(context_1.ContextProvider), -) {} -ProviderEntity.Material = MockMaterial; -ProviderEntity.Application = MockApplication; -ProviderEntity.setting = 10; -class DerivedProviderEntity extends ProviderEntity {} -DerivedProviderEntity.Material = SpecificMockMaterial; -DerivedProviderEntity.Application = SpecificMockApplication; -class ApplicationContextProvider extends (0, context_1.ApplicationContextMixin)( - context_1.ContextProvider, -) {} -ApplicationContextProvider.Application = SpecificMockApplication; -describe("Material & Application ContextMixin", () => { - const config = { name: "test" }; - it("uses static entity class", () => { - const provider = new ProviderEntity(config); - (0, chai_1.expect)(provider.material).to.be.equal("defaultMockMaterial"); - (0, chai_1.expect)(provider.application).to.be.equal("defaultMockApplication"); - }); - it("uses static entity class from derived class", () => { - const provider = new DerivedProviderEntity(config); - (0, chai_1.expect)(provider.material).to.be.equal("defaultSpecificMockMaterial"); - (0, chai_1.expect)(provider.application).to.be.equal("defaultSpecificMockApplication"); - }); -}); -describe("ContextProviderRegistryContainer", () => { - const classConfigObj = { - DataManager: { - providerCls: ProviderEntity, - config: { name: "example1", domain: "important" }, - }, - ApplicationDataManager: { - providerCls: ApplicationContextProvider, - config: { name: "example2", domain: "important" }, - }, - }; - const defaultSettings = { - ProviderEntity: { - setting: 100, - }, - }; - it("can be created and patched", () => { - const registry = (0, context_1.createAndPatchRegistry)( - classConfigObj, - { Material: SpecificMockMaterial }, - defaultSettings, - ); - const _dataProvider = registry.findProviderInstanceByName("DataManager"); - const dataProvider = new _dataProvider.constructor(_dataProvider.config); - const _appProvider = registry.findProviderInstanceByName("ApplicationDataManager"); - const appProvider = new _appProvider.constructor(_appProvider.config); - (0, chai_1.expect)(_dataProvider.constructor.setting).to.be.equal(100); - (0, chai_1.expect)(dataProvider.material).to.be.equal("defaultSpecificMockMaterial"); - (0, chai_1.expect)(appProvider.application).to.be.equal("defaultSpecificMockApplication"); - }); -}); diff --git a/tests/js/enums.d.ts b/tests/js/enums.d.ts deleted file mode 100644 index 1bb368af..00000000 --- a/tests/js/enums.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export declare const FIXTURES_DIR: string; -export declare const YAML_COMBINE_FILE: string; -export declare const YAML_LIST_TO_STRING_FILE: string; -export declare const YAML_PARAMETER_FILE: string; -export declare const YAML_ESSE_FILE: string; -export declare const YAML_INCLUDE_FILE: string; -export declare const YAML_FLATTEN_FILE: string; -export declare const YAML_READFILE_FILE: string; -export declare const YAML_CONCAT_STRING_FILE: string; diff --git a/tests/js/enums.js b/tests/js/enums.js deleted file mode 100644 index 74cd7422..00000000 --- a/tests/js/enums.js +++ /dev/null @@ -1,63 +0,0 @@ -const __createBinding = - (this && this.__createBinding) || - (Object.create - ? function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - let desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { - enumerable: true, - get() { - return m[k]; - }, - }; - } - Object.defineProperty(o, k2, desc); - } - : function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; - }); -const __setModuleDefault = - (this && this.__setModuleDefault) || - (Object.create - ? function (o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - } - : function (o, v) { - o.default = v; - }); -const __importStar = - (this && this.__importStar) || - function (mod) { - if (mod && mod.__esModule) return mod; - const result = {}; - if (mod != null) - for (const 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.YAML_CONCAT_STRING_FILE = - exports.YAML_READFILE_FILE = - exports.YAML_FLATTEN_FILE = - exports.YAML_INCLUDE_FILE = - exports.YAML_ESSE_FILE = - exports.YAML_PARAMETER_FILE = - exports.YAML_LIST_TO_STRING_FILE = - exports.YAML_COMBINE_FILE = - exports.FIXTURES_DIR = - void 0; -const path = __importStar(require("path")); - -exports.FIXTURES_DIR = path.resolve(__dirname, "./fixtures"); -exports.YAML_COMBINE_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_combine_tag.yml"); -exports.YAML_LIST_TO_STRING_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_listToString_tag.yml"); -exports.YAML_PARAMETER_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_parameter_tag.yml"); -exports.YAML_ESSE_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_esse_tag.yml"); -exports.YAML_INCLUDE_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_include_tag.yml"); -exports.YAML_FLATTEN_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_flatten_tag.yml"); -exports.YAML_READFILE_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_readFile_tag.yml"); -exports.YAML_CONCAT_STRING_FILE = path.resolve(exports.FIXTURES_DIR, "yaml_concatString_tag.yml"); diff --git a/tests/js/fixtures/rjsf_schemas.d.ts b/tests/js/fixtures/rjsf_schemas.d.ts deleted file mode 100644 index 3c2c99a9..00000000 --- a/tests/js/fixtures/rjsf_schemas.d.ts +++ /dev/null @@ -1,230 +0,0 @@ -export namespace EXAMPLE_SCHEMA { - const type: string; - namespace properties { - export namespace type_1 { - const type_2: string; - export { type_2 as type }; - } - export { type_1 as type }; - export namespace subtype { - const type_3: string; - export { type_3 as type }; - } - export namespace subsubtype { - const type_4: string; - export { type_4 as type }; - } - } -} -export namespace TREE_SIMPLE { - const path: string; - namespace data { - const key: string; - const value: string; - const name: string; - } - const children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - }[]; - }[]; -} -export namespace TREE_ADVANCED { - const path_1: string; - export { path_1 as path }; - export namespace data_1 { - const key_1: string; - export { key_1 as key }; - const value_1: string; - export { value_1 as value }; - const name_1: string; - export { name_1 as name }; - } - export { data_1 as data }; - const children_1: ( - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - }[]; - staticOptions?: undefined; - } - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - }[]; - staticOptions: { - key: string; - values: string[]; - }[]; - } - )[]; - export { children_1 as children }; - export const staticOptions: ( - | { - key: string; - values: string[]; - namesMap: { - static_a1: string; - }; - } - | { - key: string; - values: boolean[]; - namesMap?: undefined; - } - )[]; -} -export namespace UNEVEN_TREE { - const path_2: string; - export { path_2 as path }; - export namespace data_2 { - const key_2: string; - export { key_2 as key }; - const value_2: string; - export { value_2 as value }; - const name_2: string; - export { name_2 as name }; - } - export { data_2 as data }; - const children_2: ( - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children?: undefined; - } - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - }[]; - } - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: { - path: string; - data: { - key: string; - value: string; - name: string; - }; - }[]; - }[]; - } - )[]; - export { children_2 as children }; -} -export namespace TREE_STATIC_TERMINAL { - const path_3: string; - export { path_3 as path }; - export namespace data_3 { - const key_3: string; - export { key_3 as key }; - const value_3: string; - export { value_3 as value }; - const name_3: string; - export { name_3 as name }; - } - export { data_3 as data }; - const children_3: ( - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children?: undefined; - } - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - children: ( - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - staticOptions: { - key: string; - values: string[]; - }[]; - } - | { - path: string; - data: { - key: string; - value: string; - name: string; - }; - staticOptions?: undefined; - } - )[]; - } - )[]; - export { children_3 as children }; -} diff --git a/tests/js/fixtures/yaml_include_tag.yml b/tests/js/fixtures/yaml_include_tag.yml index 4956c5f9..e3e234e1 100644 --- a/tests/js/fixtures/yaml_include_tag.yml +++ b/tests/js/fixtures/yaml_include_tag.yml @@ -1,7 +1,7 @@ # include content from another Yaml file case1: here: original content - there: !include "tests/fixtures/yaml_parameter_ref.yml#/job/workflow" + there: !include "tests/js/fixtures/yaml_parameter_ref.yml#/job/workflow" # return the original data when an error occurs case2: here: original content diff --git a/tests/js/fixtures/yaml_parameter_tag.yml b/tests/js/fixtures/yaml_parameter_tag.yml index 786f9b18..9817acea 100644 --- a/tests/js/fixtures/yaml_parameter_tag.yml +++ b/tests/js/fixtures/yaml_parameter_tag.yml @@ -6,18 +6,18 @@ case1: !parameter # parse a custom !parameter tag with a ref case2: !parameter key: job.workflow - ref: tests/fixtures/yaml_parameter_ref.yml#/job.workflow # must be relative to package directory + ref: tests/js/fixtures/yaml_parameter_ref.yml#/job.workflow # must be relative to package directory # ---------------------- # parse a custom !parameter tag with a ref and exclude case3: !parameter key: workflow - ref: tests/fixtures/yaml_parameter_ref.yml#/job.workflow + ref: tests/js/fixtures/yaml_parameter_ref.yml#/job.workflow exclude: run # ---------------------- # parse a custom !parameter tag with a ref and exclude using a regular expression case4: !parameter key: job.workflow - ref: tests/fixtures/yaml_parameter_ref.yml#/job.workflow + ref: tests/js/fixtures/yaml_parameter_ref.yml#/job.workflow exclude: (run|pause) # ---------------------- # return the original data when an error occurs diff --git a/tests/js/fixtures/yaml_readFile_tag.yml b/tests/js/fixtures/yaml_readFile_tag.yml index db69653a..35afad74 100644 --- a/tests/js/fixtures/yaml_readFile_tag.yml +++ b/tests/js/fixtures/yaml_readFile_tag.yml @@ -1,2 +1,2 @@ # read contents of a file into a string -case1: !readFile "tests/fixtures/test_content.txt" +case1: !readFile "tests/js/fixtures/test_content.txt" diff --git a/tests/js/in_memory.tests.d.ts b/tests/js/in_memory.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/in_memory.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/in_memory.tests.js b/tests/js/in_memory.tests.js deleted file mode 100644 index 0d2ef28e..00000000 --- a/tests/js/in_memory.tests.js +++ /dev/null @@ -1,88 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -const base_json_1 = __importDefault( - require("@mat3ra/esse/lib/js/schema/in_memory_entity/base.json"), -); -const chai_1 = require("chai"); -const in_memory_1 = require("../../src/js/entity/in_memory"); - -class DerivedInMemoryEntity extends in_memory_1.InMemoryEntity {} -DerivedInMemoryEntity.jsonSchema = base_json_1.default; -function validateEntity(entity) { - try { - entity.validate(); - } catch (err) { - return false; - } - return true; -} -describe("InMemoryEntity", () => { - const obj = { - a: "b", - name: "test", - }; - it("can be created", () => { - const empty = new in_memory_1.InMemoryEntity(); - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(empty).to.exist; - const entity = new in_memory_1.InMemoryEntity(obj); - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(entity).to.exist; - }); - it("prop gets props", () => { - const entity = new in_memory_1.InMemoryEntity(obj); - (0, chai_1.expect)(entity.prop("a")).to.equal("b"); - (0, chai_1.expect)(entity.prop("b")).to.equal(undefined); - (0, chai_1.expect)(entity.prop("b", "a")).to.equal("a"); - }); - it("setProp sets props", () => { - const entity = new in_memory_1.InMemoryEntity(obj); - (0, chai_1.expect)(entity.prop("a")).to.equal("b"); - entity.setProp("b", "c"); - (0, chai_1.expect)(entity.prop("b")).to.equal("c"); - entity.setProp("a", "d"); - (0, chai_1.expect)(entity.prop("a")).to.equal("d"); - }); - it("unsetProp unsets props", () => { - const entity = new in_memory_1.InMemoryEntity(obj); - (0, chai_1.expect)(entity.prop("a")).to.equal("b"); - entity.unsetProp("a"); - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(entity.prop("a")).not.to.exist; - }); - it("toJSON converts to JSON", () => { - const entity = new DerivedInMemoryEntity({ _id: "123", type: "type" }); - (0, chai_1.expect)(JSON.stringify(entity.toJSON())).to.be.equal( - JSON.stringify({ _id: "123", schemaVersion: "2022.8.16" }), - ); - }); - it("jsonSchema returns correct registered schema", async () => { - (0, chai_1.expect)(DerivedInMemoryEntity.jsonSchema).to.be.an("object"); - (0, chai_1.expect)(DerivedInMemoryEntity.jsonSchema).to.have.nested.property( - "properties._id", - ); // check mix schemas - }); - it("jsonSchema validate", async () => { - const validEntity = new DerivedInMemoryEntity({ _id: "123", slug: "slug" }); - const invalidEntity = new DerivedInMemoryEntity({ _id: "123", slug: ["slug"] }); - (0, chai_1.expect)(validateEntity(validEntity)).to.be.true; - (0, chai_1.expect)(validateEntity(invalidEntity)).to.be.false; - }); - it("jsonSchema clean", async () => { - const config = { - _id: "123", - slug: "slug", - additional: "additional", - }; - const cleanConfig = new DerivedInMemoryEntity().clean({ ...config }); - (0, chai_1.expect)(cleanConfig).to.be.deep.equal({ - _id: "123", - slug: "slug", - schemaVersion: "2022.8.16", // schema's default value - }); - }); -}); diff --git a/tests/js/mixin.flowchart.tests.d.ts b/tests/js/mixin.flowchart.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/mixin.flowchart.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/mixin.flowchart.tests.js b/tests/js/mixin.flowchart.tests.js deleted file mode 100644 index 77f8bf99..00000000 --- a/tests/js/mixin.flowchart.tests.js +++ /dev/null @@ -1,87 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const entity_1 = require("../../src/js/entity"); - -const FlowchartEntity = (0, entity_1.FlowchartEntityMixin)(entity_1.InMemoryEntity); -const FlowchartItem = (0, entity_1.FlowchartItemMixin)(entity_1.InMemoryEntity); -function assertString(prop) { - (0, chai_1.expect)(prop).to.be.a("string"); - return typeof prop === "string"; -} -describe("Flowchart Mixins", () => { - it("flowchart item can be added", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - (0, chai_1.expect)(entity.units.length).to.be.equal(1); - }); - it("flowchart item can be added between two other units", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - (0, chai_1.expect)(entity.units[0].next).to.be.equal(entity.units[1].flowchartId); - const item = new FlowchartItem(); - entity.addUnit(item, 1); - (0, chai_1.expect)(entity.units[1].flowchartId).to.be.equal(item.flowchartId); - (0, chai_1.expect)(entity.units[1].next).to.be.equal(entity.units[2].flowchartId); - }); - it("flowchart item points to correct target after removal of the in-between unit", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - if (assertString(entity.units[1].flowchartId)) { - entity.removeUnit(entity.units[1].flowchartId); - } - (0, chai_1.expect)(entity.units[0].next).to.be.equal(entity.units[1].flowchartId); - }); - it("flowchart item points to correct target after removal of last unit", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - if (assertString(entity.units[2].flowchartId)) { - entity.removeUnit(entity.units[2].flowchartId); - } - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(entity.units[1].next).to.be.undefined; - }); - it("flowchart item can be removed", () => { - const entity = new FlowchartEntity(); - const item = new FlowchartItem(); - entity.addUnit(item); - entity.removeUnit(item.flowchartId); - (0, chai_1.expect)(entity.units.length).to.be.equal(0); - }); - it("flowchart item can be replaced between two other units", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - const unitsBeforeReplace = entity.units.length; - const item = new FlowchartItem(); - entity.replaceUnit(item, 1); - (0, chai_1.expect)(entity.units[1].flowchartId).to.be.equal(item.flowchartId); - (0, chai_1.expect)(entity.units.length).to.be.equal(unitsBeforeReplace); - }); - it("flowchart item can be accessed by flowchart Id", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - const item = new FlowchartItem(); - entity.addUnit(item); - const fetchedUnit = entity.getUnit(item.flowchartId); - (0, chai_1.expect)(fetchedUnit).to.be.instanceof(FlowchartItem); - (0, chai_1.expect)( - fetchedUnit === null || fetchedUnit === void 0 ? void 0 : fetchedUnit.flowchartId, - ).to.be.equal(item.flowchartId); - }); - it("flowchart item index can be found by flowchart Id", () => { - const entity = new FlowchartEntity(); - entity.addUnit(new FlowchartItem()); - entity.addUnit(new FlowchartItem()); - const item = new FlowchartItem(); - entity.addUnit(item); - const index = entity.getUnitIndexByFlowchartId(item.flowchartId); - (0, chai_1.expect)(index).to.be.equal(entity.units.length - 1); // last unit - }); -}); diff --git a/tests/js/provider.tests.d.ts b/tests/js/provider.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/provider.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/provider.tests.js b/tests/js/provider.tests.js deleted file mode 100644 index cd2ef4d5..00000000 --- a/tests/js/provider.tests.js +++ /dev/null @@ -1,22 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const provider_1 = require("../../src/js/context/provider"); - -describe("ContextProvider", () => { - const minimal = { name: "name" }; - const data = { a: "test" }; - it("can be created", () => { - const provider = new provider_1.ContextProvider(minimal); - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(provider).to.exist; - }); - it("sets and gets data", () => { - const provider = new provider_1.ContextProvider(minimal); - provider.setData(data); - (0, chai_1.expect)(() => provider.getData()).to.throw("Not implemented."); - provider.setIsEdited(true); - (0, chai_1.expect)(JSON.stringify(provider.getData())).to.equal(JSON.stringify(data)); - (0, chai_1.expect)(() => provider.defaultData).to.throw("Not implemented."); - }); - // transform, yieldData, yieldDataForRendering -}); diff --git a/tests/js/utils.d.ts b/tests/js/utils.d.ts deleted file mode 100644 index 2d5799ce..00000000 --- a/tests/js/utils.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { AnyObject } from "../../src/js/entity/in_memory"; - -export declare function assertObject(prop: unknown): prop is AnyObject; -export declare function assertArray(prop: unknown): prop is unknown[]; diff --git a/tests/js/utils.js b/tests/js/utils.js deleted file mode 100644 index 39d91e44..00000000 --- a/tests/js/utils.js +++ /dev/null @@ -1,14 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.assertArray = exports.assertObject = void 0; -const chai_1 = require("chai"); - -function assertObject(prop) { - (0, chai_1.expect)(prop).to.be.an("object"); - return Boolean(prop) && typeof prop === "object" && !Array.isArray(prop); -} -exports.assertObject = assertObject; -function assertArray(prop) { - (0, chai_1.expect)(prop).to.be.an("array"); - return Array.isArray(prop); -} -exports.assertArray = assertArray; diff --git a/tests/js/utils/class.tests.d.ts b/tests/js/utils/class.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/class.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/class.tests.js b/tests/js/utils/class.tests.js deleted file mode 100644 index 0939de22..00000000 --- a/tests/js/utils/class.tests.js +++ /dev/null @@ -1,98 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable max-classes-per-file, class-methods-use-this */ -const chai_1 = require("chai"); -const index_1 = require("../../../src/js/entity/index"); -const class_1 = require("../../../src/js/utils/class"); - -class BaseEntity extends (0, index_1.RuntimeItemsMixin)(index_1.InMemoryEntity) { - baseMethod() { - return "base"; - } -} -class ExtendClassEntity extends (0, index_1.DefaultableMixin)(index_1.NamedInMemoryEntity) { - constructor(config, excluded = []) { - super(config); - (0, class_1.extendClass)(ExtendClassEntity, BaseEntity, excluded, [config]); - } - - baseMethod() { - return "derived"; - } -} -class BaseBetweenEntity extends index_1.NamedInMemoryEntity { - constructor(config) { - super(config); - this.instanceAttr = "base"; - this.instanceAttr = "base"; - } - - betweenMethod() { - return "base"; - } -} -BaseBetweenEntity.staticAttr = "base"; -class BetweenEntity extends BaseBetweenEntity { - constructor(config) { - super(config); - this.instanceAttr = "between"; - } - - betweenMethod() { - return "between"; - } -} -BetweenEntity.staticAttr = "between"; -class ExtendThisEntity extends (0, index_1.DefaultableMixin)(BetweenEntity) { - constructor(config) { - super(config); - (0, class_1.extendThis)(ExtendThisEntity, BaseEntity, config); - } - - baseMethod() { - return "derived"; - } -} -describe("extendClass", () => { - it("extends classes no excluded props", () => { - const obj = new ExtendClassEntity({}); - (0, chai_1.expect)(obj.baseMethod()).to.be.equal("base"); - }); - it("should support excluded props but doesnt", () => { - const obj = new ExtendClassEntity({}); - (0, chai_1.expect)(obj.baseMethod()).not.to.be.equal("derived"); - }); - it("should have results but doesnt", () => { - const obj = new ExtendClassEntity({ results: ["test"] }); - (0, chai_1.expect)(JSON.stringify(obj.results)).not.to.be.equal( - JSON.stringify([{ name: "test" }]), - ); - }); -}); -describe("extendThis", () => { - it("extends this prefer child method", () => { - const obj = new ExtendThisEntity({}); - (0, chai_1.expect)(obj.baseMethod()).to.be.equal("derived"); - }); - it("extends this support base mixins", () => { - const obj = new ExtendThisEntity({ results: ["test"] }); - (0, chai_1.expect)(JSON.stringify(obj.results)).to.be.equal( - JSON.stringify([{ name: "test" }]), - ); - }); - it("remembers intermediate methods", () => { - const base = new BaseBetweenEntity({}); - (0, chai_1.expect)(base.betweenMethod()).to.be.equal("base"); - const obj = new ExtendThisEntity({}); - (0, chai_1.expect)(obj.betweenMethod()).to.be.equal("between"); - }); - it("propagates instance attributes", () => { - const base = new BaseBetweenEntity({}); - (0, chai_1.expect)(base.instanceAttr).to.be.equal("base"); - const obj = new ExtendThisEntity({}); - (0, chai_1.expect)(obj.instanceAttr).to.be.equal("between"); - }); - it("propagates static attributes", () => { - (0, chai_1.expect)(BaseBetweenEntity.staticAttr).to.be.equal("base"); - (0, chai_1.expect)(ExtendThisEntity.staticAttr).to.be.equal("between"); - }); -}); diff --git a/tests/js/utils/file.tests.d.ts b/tests/js/utils/file.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/file.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/file.tests.js b/tests/js/utils/file.tests.js deleted file mode 100644 index e4fb1f5f..00000000 --- a/tests/js/utils/file.tests.js +++ /dev/null @@ -1,11 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const file_1 = require("../../../src/js/utils/file"); - -describe("file utilities", () => { - it("should create an object path from a file path", () => { - const thisFile = "/code.js/tests/utils/file.tests.js"; - const objectPath = (0, file_1.createObjectPathFromFilePath)(thisFile, "/code.js"); - (0, chai_1.expect)(objectPath).to.be.equal("['tests']['utils']['file.tests']"); - }); -}); diff --git a/tests/js/utils/filter.tests.d.ts b/tests/js/utils/filter.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/filter.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/filter.tests.js b/tests/js/utils/filter.tests.js deleted file mode 100644 index d8bc647c..00000000 --- a/tests/js/utils/filter.tests.js +++ /dev/null @@ -1,94 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const filter_1 = require("../../../src/js/utils/filter"); - -describe("entity filter", () => { - const entities = [ - { name: "A", path: "/root/entity/a" }, - { name: "B", path: "/root/entity/b" }, - { name: "C", path: "/root/entity/c" }, - { name: "D", path: "/root/entity/d" }, - ]; - it("should filter an entity list with paths", () => { - const filterObjects = [{ path: "/root/entity/b" }, { path: "/root/entity/c" }]; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: entities, - }); - const expected = [ - { name: "B", path: "/root/entity/b" }, - { name: "C", path: "/root/entity/c" }, - ]; - (0, chai_1.expect)(filtered).to.have.deep.members(expected); - }); - it("should filter an entity list with regular expressions", () => { - const filterObjects = [{ regex: /\/root\/entity\/[bc]/ }]; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: entities, - }); - const expected = [ - { name: "B", path: "/root/entity/b" }, - { name: "C", path: "/root/entity/c" }, - ]; - (0, chai_1.expect)(filtered).to.have.deep.members(expected); - }); - it("should filter an entity list with both paths and regular expressions", () => { - const filterObjects = [{ path: "/root/entity/b" }, { regex: /\/root\/entity\/[c]/ }]; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: entities, - }); - const expected = [ - { name: "B", path: "/root/entity/b" }, - { name: "C", path: "/root/entity/c" }, - ]; - (0, chai_1.expect)(filtered).to.have.deep.members(expected); - }); - it("should filter an entity list containing concatenated paths", () => { - const filterObjects = [{ path: "/root/entity/b" }, { path: "/root/entity/c" }]; - const multiPathEntities = [ - { name: "AB", path: "/root/entity/a::/root/entity/b" }, - { name: "BC", path: "/root/entity/b::/root/entity/c" }, - ]; - const multiPathSeparator = "::"; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: multiPathEntities, - multiPathSeparator, - }); - const expected = [{ name: "BC", path: "/root/entity/b::/root/entity/c" }]; - (0, chai_1.expect)(filtered).to.have.deep.members(expected); - }); - it("should filter an entity list containing concatenated paths using regex", () => { - const filterObjects = [{ path: "/root/entity/b" }, { regex: /\/root\/entity\/[c]/ }]; - const multiPathEntities = [ - { name: "AB", path: "/root/entity/a::/root/entity/b" }, - { name: "BC", path: "/root/entity/b::/root/entity/c" }, - ]; - const multiPathSeparator = "::"; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: multiPathEntities, - multiPathSeparator, - }); - const expected = [{ name: "BC", path: "/root/entity/b::/root/entity/c" }]; - (0, chai_1.expect)(filtered).to.have.deep.members(expected); - }); - it("should return empty list if empty filter object array is given", () => { - const filterObjects = []; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: entities, - }); - (0, chai_1.expect)(filtered).to.have.length(0); - }); - it("should return empty list if no filter object array is given", () => { - const filterObjects = undefined; - const filtered = (0, filter_1.filterEntityList)({ - filterObjects, - entitiesOrPaths: entities, - }); - (0, chai_1.expect)(filtered).to.have.length(0); - }); -}); diff --git a/tests/js/utils/object.tests.d.ts b/tests/js/utils/object.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/object.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/object.tests.js b/tests/js/utils/object.tests.js deleted file mode 100644 index e4573e96..00000000 --- a/tests/js/utils/object.tests.js +++ /dev/null @@ -1,91 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const object_1 = require("../../../src/js/utils/object"); - -describe("flattenObject", () => { - it("serializes simple object", () => { - const obj = { - value: 1.0, - name: "p-norm", - degree: 2, - }; - const expectedObj = { "p-norm:degree=2": 1 }; - (0, chai_1.expect)(expectedObj).to.deep.equal((0, object_1.flattenObject)(obj)); - }); - it("serialize complex object", () => { - const obj = { - value: 1.0, - name: "p-norm", - extraProp: { - name: "zeta", - value: 6, - extraProp: { - name: "alpha", - value: 3, - veracity: 7, - }, - }, - }; - const expectedObj = { "p-norm:zeta=6:alpha=3:veracity=7": 1 }; - (0, chai_1.expect)(expectedObj).to.deep.equal((0, object_1.flattenObject)(obj)); - }); - it("throws error for wrong object", () => { - const obj = { - value: 1.0, - name: "p-norm", - degree: 2, - extraProperty: 1, - }; - (0, chai_1.expect)(() => { - (0, object_1.flattenObject)(obj); - }).to.throw(); - }); -}); -describe("mergeTerminalNodes", () => { - it("merges terminal nodes containing an array of strings", () => { - const treeStrings = { - level1: { - level2a: { - level3a: { - key1: ["a", "b", "c"], - }, - level3b: { - key2: ["d", "e", "f"], - }, - }, - }, - }; - const merged = (0, object_1.mergeTerminalNodes)(treeStrings); - (0, chai_1.expect)(merged).to.have.members(["a", "b", "c", "d", "e", "f"]); - }); - it("merges terminal nodes containing an array of objects", () => { - const treeObjects = { - level1: { - level2a: { - level3a: { - key1: [{ path: "a" }, { path: "b" }, { path: "c" }], - }, - level3b: { - key2: [{ path: "d" }, { path: "e" }, { path: "f" }], - }, - }, - }, - }; - const merged = (0, object_1.mergeTerminalNodes)(treeObjects); - (0, chai_1.expect)(merged).to.have.length(6); - (0, chai_1.expect)(merged.map((o) => o.path)).to.have.members([ - "a", - "b", - "c", - "d", - "e", - "f", - ]); - }); - it("should only merge objects", () => { - const array = [{ path: "a" }, { path: "b" }, { path: "c" }]; - // @ts-ignore - const merged = (0, object_1.mergeTerminalNodes)(array); - (0, chai_1.expect)(merged).to.have.deep.members(array); - }); -}); diff --git a/tests/js/utils/schemas.tests.d.ts b/tests/js/utils/schemas.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/schemas.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/schemas.tests.js b/tests/js/utils/schemas.tests.js deleted file mode 100644 index 7b1b31f9..00000000 --- a/tests/js/utils/schemas.tests.js +++ /dev/null @@ -1,121 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable no-unused-expressions */ -// @ts-nocheck -/* eslint-disable no-unsafe-optional-chaining */ -const chai_1 = require("chai"); -const schemas_1 = require("../../../src/js/utils/schemas"); -const rjsf_schemas_1 = require("../fixtures/rjsf_schemas"); - -describe("RJSF schema", () => { - it("dependencies block can be created from tree", () => { - const dependencies = (0, schemas_1.buildDependencies)([rjsf_schemas_1.TREE_SIMPLE]); - const [aCase] = dependencies.dependencies.type.oneOf; - (0, chai_1.expect)(aCase.properties.subtype.enum).to.have.ordered.members(["b", "c"]); - (0, chai_1.expect)(aCase.properties.subtype.enumNames).to.have.ordered.members(["B", "C"]); - const [bCase, cCase] = aCase.dependencies.subtype.oneOf; - (0, chai_1.expect)(bCase.properties.subtype.enum).to.have.length(1); - (0, chai_1.expect)(bCase.properties.subsubtype.enum).to.have.ordered.members(["d", "e"]); - (0, chai_1.expect)(bCase.properties.subsubtype.enumNames).to.have.ordered.members([ - "D", - "E", - ]); - (0, chai_1.expect)(bCase).to.not.have.property("dependencies"); - (0, chai_1.expect)(cCase.properties.subtype.enum).to.have.length(1); - (0, chai_1.expect)(cCase.properties.subsubtype.enum).to.have.ordered.members(["f", "g"]); - (0, chai_1.expect)(cCase.properties.subsubtype.enumNames).to.have.ordered.members([ - "F", - "G", - ]); - (0, chai_1.expect)(cCase).to.not.have.property("dependencies"); - }); - it("should create static options in dependency block if present in node", () => { - const dependencies = (0, schemas_1.buildDependencies)([rjsf_schemas_1.TREE_ADVANCED]); - const [aCase] = dependencies.dependencies.type.oneOf; - (0, chai_1.expect)(aCase.properties.staticA2.enum).to.have.members([true]); - (0, chai_1.expect)(aCase.properties.staticA2.enumNames).to.have.members(["true"]); - const [bCase, cCase] = aCase.dependencies.subtype.oneOf; - (0, chai_1.expect)(bCase.properties).not.to.haveOwnProperty("staticC"); - (0, chai_1.expect)(cCase.properties.staticC.enum).to.have.members(["static_c"]); - (0, chai_1.expect)(cCase.properties.staticC.enumNames).to.have.members(["static_c"]); - }); - it("should create static options from terminal nodes of dependency tree", () => { - const dependencies = (0, schemas_1.buildDependencies)([ - rjsf_schemas_1.TREE_STATIC_TERMINAL, - ]); - const [typeCase] = dependencies.dependencies.type.oneOf; - (0, chai_1.expect)(typeCase.properties.type.enum).to.have.members(["a"]); - (0, chai_1.expect)(typeCase.properties.subtype.enum).to.have.members(["b", "c"]); - const [bCase, cCase] = typeCase.dependencies.subtype.oneOf; - (0, chai_1.expect)(bCase.properties.subtype.enum).to.have.members(["b"]); - (0, chai_1.expect)(cCase.properties.subtype.enum).to.have.members(["c"]); - (0, chai_1.expect)(cCase.properties.subsubtype.enum).to.have.members(["c1", "c2"]); - const [c1Case, c2Case] = cCase.dependencies.subsubtype.oneOf; - (0, chai_1.expect)(c1Case).to.not.be.undefined; - (0, chai_1.expect)(c1Case.properties.subsubtype.enum).to.have.members(["c1"]); - (0, chai_1.expect)(c1Case.properties.static.enum).to.have.members([ - "static1", - "static2", - "static3", - ]); - (0, chai_1.expect)(c2Case).to.not.be.undefined; - (0, chai_1.expect)(c2Case.properties.subsubtype.enum).to.have.members(["c2"]); - }); - it("can be created with dependencies from schema", () => { - const rjsfSchema = (0, schemas_1.getSchemaWithDependencies)({ - schema: rjsf_schemas_1.EXAMPLE_SCHEMA, - nodes: [rjsf_schemas_1.TREE_SIMPLE], - }); - (0, chai_1.expect)(rjsfSchema.type).to.be.eql(rjsf_schemas_1.EXAMPLE_SCHEMA.type); - (0, chai_1.expect)(rjsfSchema.properties).to.be.eql( - rjsf_schemas_1.EXAMPLE_SCHEMA.properties, - ); - (0, chai_1.expect)(rjsfSchema).to.have.property("dependencies"); - }); - it("enum and enumNames can be added to schema properties", () => { - const rjsfSchema = (0, schemas_1.getSchemaWithDependencies)({ - schema: rjsf_schemas_1.EXAMPLE_SCHEMA, - nodes: [rjsf_schemas_1.TREE_SIMPLE], - modifyProperties: true, - }); - (0, chai_1.expect)(rjsfSchema.type).to.be.eql(rjsf_schemas_1.EXAMPLE_SCHEMA.type); - (0, chai_1.expect)(rjsfSchema.properties.type).to.have.property("enum"); - (0, chai_1.expect)(rjsfSchema.properties.type.enum).to.be.eql(["a"]); - (0, chai_1.expect)(rjsfSchema.properties.type).to.have.property("enumNames"); - (0, chai_1.expect)(rjsfSchema.properties.type.enumNames).to.be.eql(["A"]); - (0, chai_1.expect)(rjsfSchema).to.have.property("dependencies"); - }); - it("should correctly create dependencies from an uneven tree", () => { - const dependencies = (0, schemas_1.buildDependencies)([rjsf_schemas_1.UNEVEN_TREE]); - const [typeCase] = dependencies.dependencies.type.oneOf; - (0, chai_1.expect)(typeCase.properties.type.enum).to.have.members(["a"]); - (0, chai_1.expect)(typeCase.properties.subtype.enum).to.have.members(["b", "c", "d"]); - const [bCase, cCase, dCase] = typeCase.dependencies.subtype.oneOf; - (0, chai_1.expect)(bCase.properties.subtype.enum).to.have.members(["b"]); - (0, chai_1.expect)(cCase.properties.subtype.enum).to.have.members(["c"]); - (0, chai_1.expect)(cCase.properties.subsubtype.enum).to.have.members(["c1", "c2"]); - (0, chai_1.expect)(dCase.properties.subtype.enum).to.have.members(["d"]); - (0, chai_1.expect)(dCase.properties.subsubtype.enum).to.have.members(["d1"]); - const [xCase] = dCase.dependencies.subsubtype.oneOf; - (0, chai_1.expect)(xCase.properties.subsubtype.enum).to.have.members(["d1"]); - (0, chai_1.expect)(xCase.properties.propX.enum).to.have.members(["x"]); - }); -}); -describe("Schema utility", () => { - const schemas = [ - ["string", { type: "string" }], - ["integer", { type: "integer" }], - ["number", { type: "number" }], - ["object", { type: "object" }], - ["array", { type: "array" }], - ]; - const objSchemaNoType = { properties: { name: { type: "string" } } }; - const arraySchemaNoType = { items: { type: "number" } }; - it("type can be determined correctly", () => { - schemas.forEach(([type, schema]) => { - const currentType = (0, schemas_1.typeofSchema)(schema); - (0, chai_1.expect)(currentType).to.be.equal(type); - }); - (0, chai_1.expect)((0, schemas_1.typeofSchema)(objSchemaNoType)).to.be.equal("object"); - (0, chai_1.expect)((0, schemas_1.typeofSchema)(arraySchemaNoType)).to.be.equal("array"); - }); -}); diff --git a/tests/js/utils/str.tests.d.ts b/tests/js/utils/str.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/str.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/str.tests.js b/tests/js/utils/str.tests.js deleted file mode 100644 index cbe30cbd..00000000 --- a/tests/js/utils/str.tests.js +++ /dev/null @@ -1,70 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const utils_1 = require("../../../src/js/utils"); - -describe("str: renderTextWithSubstitutes", () => { - it("should substitute flat properties", () => { - const template = "Hello {{ user }}!"; - const data = { user: "user001" }; - const substitutionMap = { user001: "John Doe" }; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello John Doe!"); - }); - it("should substitute nested properties", () => { - const template = "Hello {{ parameters.user }}!"; - const data = { parameters: { user: "user001" } }; - const substitutionMap = { user001: "John Doe" }; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello John Doe!"); - }); - it("should leave properties without substitution unchanged", () => { - const template = "Hello {{ user }}!"; - const data = { user: "user001" }; - const substitutionMap = {}; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello user001!"); - }); - it("should return the original string if the template does not contain any variable", () => { - const template = "Hello world!"; - const data = { user: "user001" }; - const substitutionMap = {}; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello world!"); - }); - it("should return the an empty string if the template is undefined", () => { - const template = undefined; - const data = { user: "user001" }; - const substitutionMap = {}; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal(""); - }); - it("should replace the template variable with an empty string if the value is falsy", () => { - const template = "Hello {{ user }}!"; - const data = { user: null }; - const substitutionMap = {}; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello !"); - }); - it("should be able to access nested elements in template notation", () => { - const template = "Hello {{ user }} of {{ array[1]['planet'] }}!"; - const data = { user: "user001", array: [{ planet: "A" }, { planet: "B" }] }; - const substitutionMap = { - A: "Earth", - B: "Mars", - }; - const result = (0, utils_1.renderTextWithSubstitutes)(template, data, substitutionMap); - (0, chai_1.expect)(result).to.be.equal("Hello user001 of Mars!"); - }); -}); -describe("str: findPreviousVersion", () => { - const versions = ["5.4.2", "3.2", "6.2", "4", "7.2.1"]; - it("should find a previous semantic version", () => { - const previous = (0, utils_1.findPreviousVersion)(versions, "5.2"); - (0, chai_1.expect)(previous).to.be.equal("4"); - }); - it("should return undefined if no previous version is found", () => { - const previous = (0, utils_1.findPreviousVersion)(versions, "2"); - // eslint-disable-next-line no-unused-expressions - (0, chai_1.expect)(previous).to.be.undefined; - }); -}); diff --git a/tests/js/utils/tree.tests.d.ts b/tests/js/utils/tree.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/tree.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/tree.tests.js b/tests/js/utils/tree.tests.js deleted file mode 100644 index 5ade22f1..00000000 --- a/tests/js/utils/tree.tests.js +++ /dev/null @@ -1,34 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const utils_1 = require("../../../src/js/utils"); - -describe("Tree data structure", () => { - const TREE = { - path: "/A", - children: [ - { - path: "/A/B", - children: [ - { - path: "/A/B/C", - }, - ], - }, - { - path: "/A/D", - }, - ], - }; - it("map", () => { - const [mappedTree] = (0, utils_1.mapTree)([TREE], (node) => { - return { ...node, foo: "bar" }; - }); - (0, chai_1.expect)(mappedTree).to.have.property("foo", "bar"); - // @ts-ignore - (0, chai_1.expect)(mappedTree.children[0]).to.have.property("foo", "bar"); - // @ts-ignore - (0, chai_1.expect)(mappedTree.children[0].children[0]).to.have.property("foo", "bar"); - // @ts-ignore - (0, chai_1.expect)(mappedTree.children[1]).to.have.property("foo", "bar"); - }); -}); diff --git a/tests/js/utils/utils.tests.d.ts b/tests/js/utils/utils.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/utils.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/utils.tests.js b/tests/js/utils/utils.tests.js deleted file mode 100644 index 43683751..00000000 --- a/tests/js/utils/utils.tests.js +++ /dev/null @@ -1,34 +0,0 @@ -Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable no-unused-expressions */ -const chai_1 = require("chai"); -const clone_1 = require("../../../src/js/utils/clone"); -const url_1 = require("../../../src/js/utils/url"); - -describe("deepClone", () => { - const obj = { - number: 1.0, - string: "test", - array: [1.0], - object: { a: "b" }, - }; - it("clones an object", () => { - const clone = (0, clone_1.deepClone)(obj); - (0, chai_1.expect)(clone).to.deep.equal(obj); - (0, chai_1.expect)(clone); - }); - it("deep clones", () => { - const clone = (0, clone_1.deepClone)(obj); - (0, chai_1.expect)(clone).to.haveOwnProperty("object"); - delete obj.object; - const other = (0, clone_1.deepClone)(obj); - (0, chai_1.expect)(other).not.to.haveOwnProperty("object"); - }); -}); -describe("containsEncodedComponents", () => { - const decodedComponent = "a test with // special = characters?"; - const encodedComponent = encodeURIComponent(decodedComponent); - it("identifies whether a string is URL encoded", () => { - (0, chai_1.expect)((0, url_1.containsEncodedComponents)(encodedComponent)).to.be.true; - (0, chai_1.expect)((0, url_1.containsEncodedComponents)(decodedComponent)).to.be.false; - }); -}); diff --git a/tests/js/utils/yaml.combine.tests.d.ts b/tests/js/utils/yaml.combine.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.combine.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.combine.tests.js b/tests/js/utils/yaml.combine.tests.js deleted file mode 100644 index 8b007178..00000000 --- a/tests/js/utils/yaml.combine.tests.js +++ /dev/null @@ -1,122 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable no-unused-expressions */ -// @ts-nocheck -const JSONSchemasInterfaceServer_1 = __importDefault( - require("@mat3ra/esse/lib/js/esse/JSONSchemasInterfaceServer"), -); -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const lodash_1 = __importDefault(require("lodash")); -const path_1 = __importDefault(require("path")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const combineSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([ - yaml_1.combineType, - yaml_1.esseType, -]); -describe("YAML tag: !combine", () => { - let yamlFixture, parsed; - before(() => { - JSONSchemasInterfaceServer_1.default.setSchemaFolder( - path_1.default.join(__dirname, "./../fixtures/json/example"), - ); - yamlFixture = fs_1.default.readFileSync(enums_1.YAML_COMBINE_FILE, "utf8"); - parsed = js_yaml_1.default.load(yamlFixture, { schema: combineSchema }); - }); - it("should correctly parse a custom !combine tag with forEach and config keys", () => { - const expectedResult = [ - { name: "mytest", a: 1, b: 3, c: 5 }, - { name: "mytest", a: 1, b: 4, c: 5 }, - { name: "mytest", a: 2, b: 3, c: 5 }, - { name: "mytest", a: 2, b: 4, c: 5 }, - ]; - (0, chai_1.expect)(parsed.case1).to.have.deep.members(expectedResult); - }); - it("should correctly parse a custom !combine tag with only a name key", () => { - const expectedResult = [{ name: "mytest" }]; - (0, chai_1.expect)(parsed.case2).to.have.deep.members(expectedResult); - }); - it("should correctly parse a custom !combine tag with forEach key and no values", () => { - const expectedResult = [{ name: "mytest" }]; - (0, chai_1.expect)(parsed.case3).to.have.deep.members(expectedResult); - }); - it("should correctly parse a custom !combine tag with an empty forEach key and a config key", () => { - const expectedResult = [{ name: "mytest", c: 5 }]; - (0, chai_1.expect)(parsed.case4).to.have.deep.members(expectedResult); - }); - it("should correctly generate name based on template", () => { - const expectedResult = [ - { name: "A1 with B2 and C5", a: 1, b: "two", c: 5 }, - { name: "A1 with B4 and C5", a: 1, b: "four", c: 5 }, - ]; - (0, chai_1.expect)(parsed.case5).to.have.deep.members(expectedResult); - }); - it("should correctly parse a custom !combine tag with additional property", () => { - const expectedResult = [ - { name: "mytest", a: 1, b: 3 }, - { name: "mytest", a: 1, b: 4 }, - { name: "additional property", x: 7 }, - ]; - (0, chai_1.expect)(parsed.case6).to.have.deep.members(expectedResult); - }); - it("should correctly parse a custom !combine tag with additional property from !combine tag", () => { - const expectedResult = [ - { name: "mytest", a: 1, b: 3 }, - { name: "mytest", a: 1, b: 4 }, - { name: "additional property", x: 7, y: 9 }, - { name: "additional property", x: 8, y: 9 }, - ]; - (0, chai_1.expect)(parsed.case7).to.have.deep.members(expectedResult); - }); - it("should create an additional config when falsy parameter is provided", () => { - const expectedResult = [ - { name: "A1 with B2", a: 1, b: "two" }, - { name: "A1 with B4", a: 1, b: "four" }, - { name: "A1", a: 1 }, - ]; - (0, chai_1.expect)(parsed.case8).to.have.deep.members(expectedResult); - }); - it("should create all combinations of n optional parameters", () => { - const expectedResult = [ - { name: "optional params", a: 1 }, - { name: "optional params", a: 1, b: 2 }, - { name: "optional params", a: 1, b: 3 }, - { name: "optional params", a: 1, c: 4 }, - { name: "optional params", a: 1, b: 2, c: 4 }, - { name: "optional params", a: 1, b: 3, c: 4 }, - ]; - (0, chai_1.expect)(parsed.case9).to.have.deep.members(expectedResult); - }); - it("should allow to exclude certain parameter-specified combinations", () => { - const expectedResult = [{ name: "ignore test", a: { c: 3 }, d: 4 }]; - (0, chai_1.expect)(parsed.case10).to.have.deep.members(expectedResult); - }); - it("should use the push action to add value to an array parameter", () => { - const expectedResult = [ - { name: "push test", units: [{ a: 1 }, { b: 4 }] }, - { name: "push test", units: [{ a: 2 }, { b: 4 }] }, - { name: "push test", units: [{ a: 3 }, { b: 4 }] }, - { name: "push test", units: [{ a: 1 }, { b: 5 }] }, - { name: "push test", units: [{ a: 2 }, { b: 5 }] }, - { name: "push test", units: [{ a: 3 }, { b: 5 }] }, - ]; - // sort units before comparing - parsed.case11.forEach((c) => (c.units = lodash_1.default.sortBy(c.units, ["a", "b"]))); - expectedResult.forEach((c) => (c.units = lodash_1.default.sortBy(c.units, ["a", "b"]))); - (0, chai_1.expect)(parsed.case11).to.have.deep.members(expectedResult); - }); - it("should use cloned objects when pushing to array", () => { - const [config1, config2] = parsed.case12; - // deleting property in one should not affect the other - delete config1.units[1].schema; - (0, chai_1.expect)(config1.units[1].schema).to.be.undefined; - (0, chai_1.expect)(config2.units[1].schema).not.to.be.undefined; - }); -}); diff --git a/tests/js/utils/yaml.concatString.tests.d.ts b/tests/js/utils/yaml.concatString.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.concatString.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.concatString.tests.js b/tests/js/utils/yaml.concatString.tests.js deleted file mode 100644 index 9c352666..00000000 --- a/tests/js/utils/yaml.concatString.tests.js +++ /dev/null @@ -1,31 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const concatStringSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.concatStringType]); -describe("YAML tag: !concatString", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_CONCAT_STRING_FILE, "utf8"); - it("should concatenate two strings", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: concatStringSchema }); - const expected = "Hello world!"; - (0, chai_1.expect)(parsed.case1).to.be.eql(expected); - }); - it("should return a string if there is only a single item", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: concatStringSchema }); - const expected = "Hello"; - (0, chai_1.expect)(parsed.case2).to.be.eql(expected); - }); - it("should return an empty string if the array is empty", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: concatStringSchema }); - const expected = ""; - (0, chai_1.expect)(parsed.case3).to.be.eql(expected); - }); -}); diff --git a/tests/js/utils/yaml.esse.tests.d.ts b/tests/js/utils/yaml.esse.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.esse.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.esse.tests.js b/tests/js/utils/yaml.esse.tests.js deleted file mode 100644 index f54de41b..00000000 --- a/tests/js/utils/yaml.esse.tests.js +++ /dev/null @@ -1,58 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -// @ts-nocheck -const JSONSchemasInterfaceServer_1 = __importDefault( - require("@mat3ra/esse/lib/js/esse/JSONSchemasInterfaceServer"), -); -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const path_1 = __importDefault(require("path")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const yamlSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.esseType]); -describe("YAML tag: !esse", () => { - let yamlFixture, parsed; - before(() => { - JSONSchemasInterfaceServer_1.default.setSchemaFolder( - path_1.default.join(__dirname, "./../fixtures/json/example"), - ); - yamlFixture = fs_1.default.readFileSync(enums_1.YAML_ESSE_FILE, "utf8"); - parsed = js_yaml_1.default.load(yamlFixture, { schema: yamlSchema }); - }); - it("should correctly parse a custom !esse tag and return ESSE schema", () => { - const expected = { - $id: "core/primitive/scalar", - $schema: "http://json-schema.org/draft-07/schema#", - title: "scalar schema", - type: "object", - required: ["value"], - properties: { - value: { - type: "number", - }, - }, - }; - (0, chai_1.expect)(parsed.case1).to.eql(expected); - }); - it("should return the original data when an error occurs", () => { - (0, chai_1.expect)(parsed.case2).to.be.equal("non-existent-schema-id"); - }); - it("should parse a custom !esse tag and return a value from the ESSE schema", () => { - const expected = ["kbar", "pa"]; - (0, chai_1.expect)(parsed.case3).to.have.deep.members(expected); - }); - it("should correctly return nested value from esse schema", () => { - const expected = "array containing values of x Axis"; - (0, chai_1.expect)(parsed.case4).to.be.eql(expected); - }); - it("should correctly return array item from esse schema", () => { - const expected = "yDataSeries"; - (0, chai_1.expect)(parsed.case5).to.be.eql(expected); - }); -}); diff --git a/tests/js/utils/yaml.flatten.tests.d.ts b/tests/js/utils/yaml.flatten.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.flatten.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.flatten.tests.js b/tests/js/utils/yaml.flatten.tests.js deleted file mode 100644 index d540b966..00000000 --- a/tests/js/utils/yaml.flatten.tests.js +++ /dev/null @@ -1,21 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const flattenSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.flattenType]); -describe("YAML tag: !flatten", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_FLATTEN_FILE, "utf8"); - it("should convert an array of arrays into a flattened array", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: flattenSchema }); - const expected = ["a", "b", "c", "d", "e", "f"]; - (0, chai_1.expect)(parsed.case1).to.be.eql(expected); - }); -}); diff --git a/tests/js/utils/yaml.include.tests.d.ts b/tests/js/utils/yaml.include.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.include.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.include.tests.js b/tests/js/utils/yaml.include.tests.js deleted file mode 100644 index b47b28d6..00000000 --- a/tests/js/utils/yaml.include.tests.js +++ /dev/null @@ -1,33 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -// @ts-nocheck -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const includeSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.includeType]); -describe("YAML tag: !include", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_INCLUDE_FILE, "utf8"); - it("should correctly include content from another Yaml file", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: includeSchema }); - const expected = { - here: "original content", - there: ["run", "stop", "pause"], - }; - (0, chai_1.expect)(parsed.case1).to.be.eql(expected); - }); - it("should return the original data when an error occurs", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: includeSchema }); - const expected = { - here: "original content", - there: "nonexistent_file.txt", - }; - (0, chai_1.expect)(parsed.case2).to.be.eql(expected); - }); -}); diff --git a/tests/js/utils/yaml.include.tests.ts b/tests/js/utils/yaml.include.tests.ts index 31b9870b..e3fc6e6c 100644 --- a/tests/js/utils/yaml.include.tests.ts +++ b/tests/js/utils/yaml.include.tests.ts @@ -4,7 +4,6 @@ import fs from "fs"; import yaml from "js-yaml"; import { includeType } from "../../../src/js/utils/yaml"; -// @ts-ignore import { YAML_INCLUDE_FILE } from "../enums"; const includeSchema = yaml.DEFAULT_SCHEMA.extend([includeType]); diff --git a/tests/js/utils/yaml.listToString.tests.d.ts b/tests/js/utils/yaml.listToString.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.listToString.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.listToString.tests.js b/tests/js/utils/yaml.listToString.tests.js deleted file mode 100644 index 29adce07..00000000 --- a/tests/js/utils/yaml.listToString.tests.js +++ /dev/null @@ -1,33 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -// @ts-nocheck -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const includeSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.listToStringType]); -describe("YAML tag: !listToString", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_LIST_TO_STRING_FILE, "utf8"); - it("should correctly concatenate content from list to string", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: includeSchema }); - const expected = { - here: "original content", - there: "onetwo", - }; - (0, chai_1.expect)(parsed.case1).to.be.eql(expected); - }); - it("should correctly filter out and concatenate only strings from list", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: includeSchema }); - const expected = { - here: "original content", - there: "onetwo", - }; - (0, chai_1.expect)(parsed.case2).to.be.eql(expected); - }); -}); diff --git a/tests/js/utils/yaml.parameter.tests.d.ts b/tests/js/utils/yaml.parameter.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.parameter.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.parameter.tests.js b/tests/js/utils/yaml.parameter.tests.js deleted file mode 100644 index 5baa7b7a..00000000 --- a/tests/js/utils/yaml.parameter.tests.js +++ /dev/null @@ -1,61 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -// @ts-nocheck -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const parameterSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.parameterType]); -describe("YAML tag: !parameter", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_PARAMETER_FILE, "utf8"); - it("should correctly parse a custom !parameter tag with a key and values", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case1).to.be.eql({ key: "some.key", values: ["a", "b", "c"] }); - }); - it("should correctly parse a custom !parameter tag with a ref", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case2).to.be.eql({ - key: "job.workflow", - values: ["run", "stop", "pause"], - }); - }); - it("should correctly parse a custom !parameter tag with a ref and exclude", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case3).to.be.eql({ key: "workflow", values: ["stop", "pause"] }); - }); - it("should correctly parse a custom !parameter tag with a ref and exclude using a regular expression", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case4).to.be.eql({ key: "job.workflow", values: ["stop"] }); - }); - it("should return the original data when an error occurs", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case5).to.be.eql({ - key: "error.key", - ref: "non_existent_file.yaml", - }); - }); - it("should add null to values array when isOptional is true", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case6).to.be.eql({ - key: "some.key", - values: ["a", "b", "c", null], - }); - }); - it("should exclude values using regex and add null for optional parameters", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case7).to.be.eql({ key: "some.key", values: ["a", "c", null] }); - }); - it("should merge values with locally defined items and arrays", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: parameterSchema }); - (0, chai_1.expect)(parsed.case8).to.be.eql({ - key: "merged", - values: ["a", "b", "c", "d", "e"], - }); - }); -}); diff --git a/tests/js/utils/yaml.readFile.tests.d.ts b/tests/js/utils/yaml.readFile.tests.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/tests/js/utils/yaml.readFile.tests.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tests/js/utils/yaml.readFile.tests.js b/tests/js/utils/yaml.readFile.tests.js deleted file mode 100644 index ef073388..00000000 --- a/tests/js/utils/yaml.readFile.tests.js +++ /dev/null @@ -1,22 +0,0 @@ -const __importDefault = - (this && this.__importDefault) || - function (mod) { - return mod && mod.__esModule ? mod : { default: mod }; - }; -Object.defineProperty(exports, "__esModule", { value: true }); -const chai_1 = require("chai"); -const fs_1 = __importDefault(require("fs")); -const js_yaml_1 = __importDefault(require("js-yaml")); -const yaml_1 = require("../../../src/js/utils/yaml"); -const enums_1 = require("../enums"); - -const readFileSchema = js_yaml_1.default.DEFAULT_SCHEMA.extend([yaml_1.readFileType]); -describe("YAML tag: !readFile", () => { - const yamlFixture = fs_1.default.readFileSync(enums_1.YAML_READFILE_FILE, "utf8"); - it("should read contents of a file into a string", () => { - const parsed = js_yaml_1.default.load(yamlFixture, { schema: readFileSchema }); - const expected = "Example text\nwith linebreaks.\n"; - (0, chai_1.expect)(parsed.case1).to.be.a("string"); - (0, chai_1.expect)(parsed.case1).to.be.eql(expected); - }); -}); diff --git a/tsconfig.json b/tsconfig.json index 89becc35..907187f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,37 +1,23 @@ { "compilerOptions": { - /* Basic Options */ - "target": "es2019", - "module": "esNext", - "allowJs": true, + "target": "ES2018", "jsx": "react", - "incremental": true, - "noEmit": true, - "outDir": "./dist", - - /* Strict Type-Checking Options */ - "strict": true, - "noImplicitAny": false, - "strictNullChecks": true, - "experimentalDecorators": true, - - /* Additional Checks */ - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": false, - "noFallthroughCasesInSwitch": false, - - /* Module Resolution Options */ - "baseUrl": "./src/js", - "rootDir": "./src/js", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, + "lib": ["ES2019", "dom"], + "allowJs": true, + "module": "commonjs", + "moduleResolution": "Node", "declaration": true, + "outDir": "./dist", + "noEmitOnError": false, "isolatedModules": true, + "esModuleInterop": true, + "resolveJsonModule": true, "forceConsistentCasingInFileNames": true, + "strict": true, "skipLibCheck": true, - "types": ["mocha", "node"] + "types": ["mocha", "node"], + "rootDir": "./src/js", + "baseUrl": "./", }, "include": [ "./src/js"