From 9681bd1acbf03cc581dad4bb0611b3958d87c3bf Mon Sep 17 00:00:00 2001 From: Mert Karaca Date: Wed, 3 Jul 2024 14:13:34 +0200 Subject: [PATCH] Add typings generation tests for non-linked attribute property with reference sets --- .../typings-generator/__tests__/index.spec.ts | 18 ++++ .../non-linked-list-attribute-refset.ts | 95 +++++++++++++++++++ .../non-linked-list-attribute-refset.ts | 43 +++++++++ 3 files changed, 156 insertions(+) create mode 100644 packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/non-linked-list-attribute-refset.ts create mode 100644 packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/non-linked-list-attribute-refset.ts diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts index 36bac306..8a834357 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts @@ -31,6 +31,14 @@ import { selectionInput, selectionInputNative } from "./inputs/selection"; import { selectionNativeOutput, selectionWebOutput } from "./outputs/selection"; import { listAttributeNativeInput, listAttributeWebInput } from "./inputs/list-attribute-refset"; import { listAttributeNativeOutput, listAttributeWebOutput } from "./outputs/list-attribute-refset"; +import { + nonLinkedListAttributeNativeInput, + nonLinkedListAttributeWebInput +} from "./inputs/non-linked-list-attribute-refset"; +import { + nonLinkedListAttributeNativeOutput, + nonLinkedListAttributeWebOutput +} from "./outputs/non-linked-list-attribute-refset"; describe("Generating tests", () => { it("Generates a parsed typing from XML for native", () => { @@ -182,6 +190,16 @@ describe("Generating tests", () => { const newContent = generateNativeTypesFor(listAttributeNativeInput); expect(newContent).toBe(listAttributeNativeOutput); }); + + it("Generates a parsed typing from XML for web using ref sets in non-linked attribute", () => { + const newContent = generateFullTypesFor(nonLinkedListAttributeWebInput); + expect(newContent).toBe(nonLinkedListAttributeWebOutput); + }); + + it("Generates a parsed typing from XML for native using ref sets in non-linked attribute", () => { + const newContent = generateNativeTypesFor(nonLinkedListAttributeNativeInput); + expect(newContent).toBe(nonLinkedListAttributeNativeOutput); + }); }); function generateFullTypesFor(xml: string) { diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/non-linked-list-attribute-refset.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/non-linked-list-attribute-refset.ts new file mode 100644 index 00000000..d699d295 --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/non-linked-list-attribute-refset.ts @@ -0,0 +1,95 @@ +export const nonLinkedListAttributeWebInput = ` + + + + + Reference + + + + + + + Reference + + + + + + + + + + Reference Set + + + + + + + + + + Reference or Set + + + + + + + + + + + +`; + +export const nonLinkedListAttributeNativeInput = ` + + + + + Reference + + + + + + + Reference + + + + + + + + + + Reference Set + + + + + + + + + + Reference or Set + + + + + + + + + + + +`; \ No newline at end of file diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/non-linked-list-attribute-refset.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/non-linked-list-attribute-refset.ts new file mode 100644 index 00000000..47e80c50 --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/non-linked-list-attribute-refset.ts @@ -0,0 +1,43 @@ +export const nonLinkedListAttributeWebOutput = `/** + * This file was generated from MyWidget.xml + * WARNING: All changes made to this file will be overwritten + * @author Mendix Widgets Framework Team + */ +import { CSSProperties } from "react"; +import { EditableValue, EditableListValue } from "mendix"; + +export interface MyWidgetContainerProps { + name: string; + class: string; + style?: CSSProperties; + tabIndex?: number; + referenceDefault: EditableValue; + reference: EditableValue; + referenceSet: EditableListValue; + referenceOrSet: EditableValue | EditableListValue; +} + +export interface MyWidgetPreviewProps { + /** + * @deprecated Deprecated since version 9.18.0. Please use class property instead. + */ + className: string; + class: string; + style: string; + styleObject?: CSSProperties; + readOnly: boolean; + referenceDefault: string; + reference: string; + referenceSet: string; + referenceOrSet: string; +} +`; + +export const nonLinkedListAttributeNativeOutput = `export interface MyWidgetProps