@komaci/esm-generator 264.4.0 → 266.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/genericAstGeneration.js +80 -34
- package/package.json +1 -1
- package/build/__tests__/adgAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/adgAstGeneration.spec.js +0 -447
- package/build/__tests__/compile-generated-module-fixtures.spec.d.ts +0 -2
- package/build/__tests__/compile-generated-module-fixtures.spec.js +0 -49
- package/build/__tests__/compilerConfigs.d.ts +0 -24
- package/build/__tests__/compilerConfigs.js +0 -126
- package/build/__tests__/compositionAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/compositionAstGeneration.spec.js +0 -676
- package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.js +0 -28
- package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.d.ts +0 -29
- package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.js +0 -148
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.d.ts +0 -9
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.js +0 -35
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.d.ts +0 -10
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.js +0 -39
- package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-combined-files/image-type/actual.d.ts +0 -13
- package/build/__tests__/fixtures-combined-files/image-type/actual.js +0 -41
- package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.d.ts +0 -14
- package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.js +0 -79
- package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.d.ts +0 -18
- package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.js +0 -103
- package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.js +0 -28
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.js +0 -16
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.d.ts +0 -4
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.js +0 -18
- package/build/__tests__/fixtures-combined-files/include-template-strings/actual.d.ts +0 -10
- package/build/__tests__/fixtures-combined-files/include-template-strings/actual.js +0 -41
- package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.d.ts +0 -9
- package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.js +0 -38
- package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.d.ts +0 -1
- package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.js +0 -2
- package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
- package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.d.ts +0 -5
- package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.js +0 -14
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.js +0 -31
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.js +0 -27
- package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.d.ts +0 -15
- package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.js +0 -104
- package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.d.ts +0 -8
- package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.js +0 -13
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.js +0 -10
- package/build/__tests__/fixtures-script-files/class-props/actual.d.ts +0 -30
- package/build/__tests__/fixtures-script-files/class-props/actual.js +0 -103
- package/build/__tests__/fixtures-script-files/empty-class/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/empty-class/actual.js +0 -7
- package/build/__tests__/fixtures-script-files/empty-doc/actual.d.ts +0 -1
- package/build/__tests__/fixtures-script-files/empty-doc/actual.js +0 -2
- package/build/__tests__/fixtures-script-files/empty-wire/actual.d.ts +0 -5
- package/build/__tests__/fixtures-script-files/empty-wire/actual.js +0 -16
- package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-script-files/exports/actual.d.ts +0 -22
- package/build/__tests__/fixtures-script-files/exports/actual.js +0 -63
- package/build/__tests__/fixtures-script-files/imports/actual.d.ts +0 -11
- package/build/__tests__/fixtures-script-files/imports/actual.js +0 -80
- package/build/__tests__/fixtures-script-files/imports-namespaced/actual.d.ts +0 -10
- package/build/__tests__/fixtures-script-files/imports-namespaced/actual.js +0 -63
- package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.d.ts +0 -3
- package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.js +0 -10
- package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.d.ts +0 -9
- package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.js +0 -24
- package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
- package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
- package/build/__tests__/fixtures-script-files/wire-basic/actual.d.ts +0 -8
- package/build/__tests__/fixtures-script-files/wire-basic/actual.js +0 -30
- package/build/__tests__/fixtures-script-files/wire-functions/actual.d.ts +0 -13
- package/build/__tests__/fixtures-script-files/wire-functions/actual.js +0 -46
- package/build/__tests__/fixtures-script-files/wire-imports/actual.d.ts +0 -11
- package/build/__tests__/fixtures-script-files/wire-imports/actual.js +0 -63
- package/build/__tests__/fixtures-source-code/badImportRef.d.ts +0 -4
- package/build/__tests__/fixtures-source-code/badImportRef.js +0 -31
- package/build/__tests__/fixtures-source-code/generalMockSourceCode.d.ts +0 -8
- package/build/__tests__/fixtures-source-code/generalMockSourceCode.js +0 -127
- package/build/__tests__/fixtures-source-code/gqlMockSource.d.ts +0 -3
- package/build/__tests__/fixtures-source-code/gqlMockSource.js +0 -95
- package/build/__tests__/functionAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/functionAstGeneration.spec.js +0 -727
- package/build/__tests__/general-komaci-docs/assorted-template-strings/source.d.ts +0 -10
- package/build/__tests__/general-komaci-docs/assorted-template-strings/source.js +0 -41
- package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.d.ts +0 -7
- package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.js +0 -31
- package/build/__tests__/general-komaci-docs/import-types/source.d.ts +0 -18
- package/build/__tests__/general-komaci-docs/import-types/source.js +0 -108
- package/build/__tests__/general-komaci-docs/import-types/validationStuff.d.ts +0 -18
- package/build/__tests__/general-komaci-docs/import-types/validationStuff.js +0 -63
- package/build/__tests__/general-komaci-docs/template-component/source.d.ts +0 -8
- package/build/__tests__/general-komaci-docs/template-component/source.js +0 -34
- package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.d.ts +0 -2
- package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.js +0 -20
- package/build/__tests__/generated-module/lightning/component/component.d.ts +0 -18
- package/build/__tests__/generated-module/lightning/component/component.js +0 -168
- package/build/__tests__/genericAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/genericAstGeneration.spec.js +0 -1052
- package/build/__tests__/index.spec.d.ts +0 -2
- package/build/__tests__/index.spec.js +0 -393
- package/build/__tests__/komaci-ast-unit.spec.d.ts +0 -2
- package/build/__tests__/komaci-ast-unit.spec.js +0 -422
- package/build/__tests__/komaci-bundle-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-bundle-module.fixtures.spec.js +0 -76
- package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.js +0 -117
- package/build/__tests__/komaci-gql.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-gql.fixtures.spec.js +0 -51
- package/build/__tests__/komaci-script-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-script-module.fixtures.spec.js +0 -70
- package/build/__tests__/komaci-template-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-template-module.fixtures.spec.js +0 -57
- package/build/__tests__/readAndParseBundle.d.ts +0 -22
- package/build/__tests__/readAndParseBundle.js +0 -80
|
@@ -1,676 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const compositionAstGeneration_1 = require("../compositionAstGeneration");
|
|
30
|
-
const types_1 = require("@babel/types");
|
|
31
|
-
const types_2 = require("../types");
|
|
32
|
-
const fs = __importStar(require("fs"));
|
|
33
|
-
const path_1 = require("path");
|
|
34
|
-
const common_shared_1 = require("@komaci/common-shared");
|
|
35
|
-
const generator_1 = __importDefault(require("@babel/generator"));
|
|
36
|
-
const complexDoc = JSON.parse(fs.readFileSync((0, path_1.join)(__dirname, './general-komaci-docs/complexTemplateDoc/template.json'), 'utf-8'));
|
|
37
|
-
describe('imageToExpression', () => {
|
|
38
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
39
|
-
it('should return an expression for a KomaciDocument Image node', () => {
|
|
40
|
-
const komaciDocImagePrimitive = {
|
|
41
|
-
type: 'Image',
|
|
42
|
-
src: {
|
|
43
|
-
type: 'PrimitiveValue',
|
|
44
|
-
value: 'testPrimitive.jpg', // this is string literal of a relative URL
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
let expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImagePrimitive);
|
|
48
|
-
expect(expression.type).toBe('CallExpression');
|
|
49
|
-
let callExpression = expression;
|
|
50
|
-
expect(callExpression).not.toBeUndefined();
|
|
51
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
52
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
53
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
54
|
-
expect(callExpression.arguments[0]).not.toBeUndefined();
|
|
55
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
56
|
-
let objExpression = callExpression
|
|
57
|
-
.arguments[0];
|
|
58
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
59
|
-
expect(objExpression.properties).toHaveLength(1);
|
|
60
|
-
expect(objExpression.properties[0].type).toBe('ObjectProperty');
|
|
61
|
-
let objProperty = objExpression.properties[0];
|
|
62
|
-
expect(objProperty.key).toBe(types_2.ID.IMG_SRC);
|
|
63
|
-
expect(objProperty.value.properties[1]
|
|
64
|
-
.value).toEqual((0, types_1.stringLiteral)('testPrimitive.jpg')); // img({src: "testPrimitive.jpg"})
|
|
65
|
-
const komaciDocImageBinding = {
|
|
66
|
-
type: 'Image',
|
|
67
|
-
src: {
|
|
68
|
-
type: 'Binding',
|
|
69
|
-
value: 'testBinding', // this is a string literal, but represents a variable name
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImageBinding);
|
|
73
|
-
expect(expression.type).toBe('CallExpression');
|
|
74
|
-
callExpression = expression;
|
|
75
|
-
expect(callExpression).not.toBeUndefined();
|
|
76
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
77
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
78
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
79
|
-
expect(callExpression.arguments[0]).not.toBeUndefined();
|
|
80
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
81
|
-
objExpression = callExpression.arguments[0];
|
|
82
|
-
expect(objExpression).not.toBeUndefined();
|
|
83
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
84
|
-
expect(objExpression.properties).toHaveLength(1);
|
|
85
|
-
expect(objExpression.properties[0].type).toBe('ObjectProperty');
|
|
86
|
-
objProperty = objExpression.properties[0];
|
|
87
|
-
expect(objProperty.key).toBe(types_2.ID.IMG_SRC);
|
|
88
|
-
const segments = ['ctx', 'props', 'testBinding'];
|
|
89
|
-
let expr = (0, types_1.identifier)(segments[0]);
|
|
90
|
-
for (let i = 1; i < segments.length; i++) {
|
|
91
|
-
expr = (0, types_1.optionalMemberExpression)(expr, (0, types_1.identifier)(segments[i]), false, false);
|
|
92
|
-
}
|
|
93
|
-
expect(objProperty.value.properties[1]
|
|
94
|
-
.value).toEqual((0, types_1.stringLiteral)('testBinding')); // img({src: ctx.props.testBinding})
|
|
95
|
-
const komaciDocImageNestedBinding = {
|
|
96
|
-
type: 'Image',
|
|
97
|
-
src: {
|
|
98
|
-
type: 'Binding',
|
|
99
|
-
value: 'imageObject/nested/imageName', // this is a string literal, represents nested-scoped variable names
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImageNestedBinding);
|
|
103
|
-
expect(expression.type).toBe('CallExpression');
|
|
104
|
-
callExpression = expression;
|
|
105
|
-
expect(callExpression).not.toBeUndefined();
|
|
106
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
107
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
108
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
109
|
-
expect(callExpression.arguments[0]).not.toBeUndefined();
|
|
110
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
111
|
-
objExpression = callExpression.arguments[0];
|
|
112
|
-
expect(objExpression).not.toBeUndefined();
|
|
113
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
114
|
-
expect(objExpression.properties).toHaveLength(1);
|
|
115
|
-
expect(objExpression.properties[0].type).toBe('ObjectProperty');
|
|
116
|
-
objProperty = objExpression.properties[0];
|
|
117
|
-
expect(objProperty.key).toBe(types_2.ID.IMG_SRC);
|
|
118
|
-
expect(objProperty.value.properties[1]
|
|
119
|
-
.value).toEqual((0, types_1.stringLiteral)('imageObject.nested.imageName'));
|
|
120
|
-
});
|
|
121
|
-
it('should not return an expression for invalid KomaciDocument Image nodes due to invalid src.value type (boolean)', () => {
|
|
122
|
-
const komaciDocImagePrimitive = {
|
|
123
|
-
type: 'Image',
|
|
124
|
-
src: {
|
|
125
|
-
type: 'PrimitiveValue',
|
|
126
|
-
value: false, // not a supported type (boolean)
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
const expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImagePrimitive);
|
|
130
|
-
expect(expression.type).toBe('CallExpression');
|
|
131
|
-
const callExpression = expression;
|
|
132
|
-
expect(callExpression).not.toBeUndefined();
|
|
133
|
-
expect(callExpression.callee).not.toBeUndefined();
|
|
134
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
135
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
136
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
137
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
138
|
-
const objExpression = callExpression
|
|
139
|
-
.arguments[0];
|
|
140
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
141
|
-
expect(objExpression.properties).toHaveLength(0); // no img() populated with a valid src attribute
|
|
142
|
-
});
|
|
143
|
-
it('should not return an expression for invalid KomaciDocument Image nodes due to blank src.value', () => {
|
|
144
|
-
const komaciDocImagePrimitiveBlank = {
|
|
145
|
-
type: 'Image',
|
|
146
|
-
src: {
|
|
147
|
-
type: 'PrimitiveValue',
|
|
148
|
-
value: '', // blanks not supported
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
let expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImagePrimitiveBlank);
|
|
152
|
-
expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImagePrimitiveBlank);
|
|
153
|
-
expect(expression.type).toBe('CallExpression');
|
|
154
|
-
const callExpression = expression;
|
|
155
|
-
expect(callExpression).not.toBeUndefined();
|
|
156
|
-
expect(callExpression.callee).not.toBeUndefined();
|
|
157
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
158
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
159
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
160
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
161
|
-
const objExpression = callExpression
|
|
162
|
-
.arguments[0];
|
|
163
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
164
|
-
expect(objExpression.properties).toHaveLength(0); // no img() populated with a valid src attribute
|
|
165
|
-
});
|
|
166
|
-
it('should not return an expression for invalid KomaciDocument Image nodes with src.type that is neither Binding nor PrimitiveType', () => {
|
|
167
|
-
const komaciDocImageInvalidSrcValType = {
|
|
168
|
-
type: 'Image',
|
|
169
|
-
src: {
|
|
170
|
-
type: 'PrimitiveValue',
|
|
171
|
-
value: 'some random string',
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
// change the src.value type to something invalid, a number
|
|
175
|
-
komaciDocImageInvalidSrcValType.src.value = 12345;
|
|
176
|
-
let expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImageInvalidSrcValType);
|
|
177
|
-
expression = (0, compositionAstGeneration_1.imageToExpression)(moduleMetadata, komaciDocImageInvalidSrcValType);
|
|
178
|
-
expect(expression.type).toBe('CallExpression');
|
|
179
|
-
const callExpression = expression;
|
|
180
|
-
expect(callExpression).not.toBeUndefined();
|
|
181
|
-
expect(callExpression.callee).not.toBeUndefined();
|
|
182
|
-
expect(callExpression.callee).toBe(types_2.ID.IMG_FUNC);
|
|
183
|
-
expect(callExpression.arguments).not.toBeUndefined();
|
|
184
|
-
expect(callExpression.arguments).toHaveLength(2);
|
|
185
|
-
expect(callExpression.arguments[0].type).toBe('ObjectExpression');
|
|
186
|
-
const objExpression = callExpression
|
|
187
|
-
.arguments[0];
|
|
188
|
-
expect(objExpression.properties).not.toBeUndefined();
|
|
189
|
-
expect(objExpression.properties).toHaveLength(0);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
describe('compositionToArrayExpression', () => {
|
|
193
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
194
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata, 0);
|
|
195
|
-
it('could handle a single composition', () => {
|
|
196
|
-
const res = (0, compositionAstGeneration_1.compositionsToArrayExpression)(moduleMetadata, [
|
|
197
|
-
complexDoc.compositions[0].compositions[2].compositions[0],
|
|
198
|
-
]);
|
|
199
|
-
expect(res?.elements).toHaveLength(1);
|
|
200
|
-
});
|
|
201
|
-
it('can handle multiple compositions being passed in', () => {
|
|
202
|
-
const res = (0, compositionAstGeneration_1.compositionsToArrayExpression)(moduleMetadata, complexDoc.compositions[0].compositions);
|
|
203
|
-
expect(res?.elements).toHaveLength(3);
|
|
204
|
-
});
|
|
205
|
-
it('returns an empty array when given an empty array element of compositions', () => {
|
|
206
|
-
const res = (0, compositionAstGeneration_1.compositionsToArrayExpression)(moduleMetadata, []);
|
|
207
|
-
expect(res?.elements).toHaveLength(0);
|
|
208
|
-
});
|
|
209
|
-
it('returns undefined if we are given no compositions', () => {
|
|
210
|
-
const res = (0, compositionAstGeneration_1.compositionsToArrayExpression)(moduleMetadata, undefined);
|
|
211
|
-
expect(res).toBeUndefined();
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
describe('compositionToExpression', () => {
|
|
215
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
216
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata, 0);
|
|
217
|
-
moduleMetadata.adgs.set(0, (0, common_shared_1.initAdgMetadataObject)('adg0'));
|
|
218
|
-
(0, common_shared_1.addTemplateUsageForAdg)(complexDoc, 0, moduleMetadata);
|
|
219
|
-
it('effectively builds a conditional expression for a component with isActive', () => {
|
|
220
|
-
const res = (0, compositionAstGeneration_1.compositionToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[2].compositions[1]);
|
|
221
|
-
expect(res.type).toBe('CallExpression');
|
|
222
|
-
expect(res.callee).toBe(types_2.ID.CONDITION_FUNC);
|
|
223
|
-
const code = (0, generator_1.default)(res).code;
|
|
224
|
-
expect(code).toBe(`c(ctx, {
|
|
225
|
-
c: {
|
|
226
|
-
t: "b",
|
|
227
|
-
v: "apexResult"
|
|
228
|
-
},
|
|
229
|
-
slot: ""
|
|
230
|
-
}, ctx => [i({
|
|
231
|
-
c: {
|
|
232
|
-
t: "b",
|
|
233
|
-
v: "apexResult.data.names"
|
|
234
|
-
}
|
|
235
|
-
}, ctx, user_var_test => {
|
|
236
|
-
return [e({}, ctx, []), cg(i4, {
|
|
237
|
-
componentId: "c-name-detail",
|
|
238
|
-
props: ctx => ({
|
|
239
|
-
name: user_var_test.value?.name
|
|
240
|
-
})
|
|
241
|
-
}, ctx, [], [])];
|
|
242
|
-
}), c(ctx, {
|
|
243
|
-
c: {
|
|
244
|
-
t: "b",
|
|
245
|
-
v: "apexResult.data"
|
|
246
|
-
}
|
|
247
|
-
}, ctx => i({
|
|
248
|
-
c: {
|
|
249
|
-
t: "b",
|
|
250
|
-
v: "apexResult.data"
|
|
251
|
-
}
|
|
252
|
-
}, ctx, user_var_contactName => {
|
|
253
|
-
return [e({}, ctx, [])];
|
|
254
|
-
}), false), c(ctx, {
|
|
255
|
-
c: {
|
|
256
|
-
t: "b",
|
|
257
|
-
v: "apexResult.error"
|
|
258
|
-
}
|
|
259
|
-
}, ctx => [], false)], false)`);
|
|
260
|
-
});
|
|
261
|
-
it('effectiely builds a conditional expression for a component with negated isActive', () => {
|
|
262
|
-
const res = (0, compositionAstGeneration_1.compositionToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[2].compositions[2]);
|
|
263
|
-
expect(res.type).toBe('CallExpression');
|
|
264
|
-
expect(res.callee).toBe(types_2.ID.CONDITION_FUNC);
|
|
265
|
-
const code = (0, generator_1.default)(res).code;
|
|
266
|
-
expect(code).toBe(`c(ctx, {
|
|
267
|
-
c: {
|
|
268
|
-
t: "b",
|
|
269
|
-
v: "apexResult"
|
|
270
|
-
},
|
|
271
|
-
slot: ""
|
|
272
|
-
}, ctx => [], true)`);
|
|
273
|
-
});
|
|
274
|
-
it('returns a basic reference when isActive is not set', () => {
|
|
275
|
-
const res = (0, compositionAstGeneration_1.compositionToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[2].compositions[0]);
|
|
276
|
-
expect(res.type).toBe('CallExpression');
|
|
277
|
-
const code = (0, generator_1.default)(res).code;
|
|
278
|
-
expect(code).toBe('cg(i1, {\n slot: "title",\n componentId: "c-title",\n props: ctx => ({\n icon: "standard:apex",\n size: "medium"\n })\n}, ctx, [], [])');
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
describe('containerToExpression', () => {
|
|
282
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
283
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata, 0);
|
|
284
|
-
it('uses the element function when container has a key', () => {
|
|
285
|
-
const container = Object.assign({}, complexDoc.compositions[0].compositions[2].compositions[0]);
|
|
286
|
-
container.key = { type: 'Binding', value: 'test' };
|
|
287
|
-
const res = (0, compositionAstGeneration_1.containerToExpression)(moduleMetadata, container);
|
|
288
|
-
expect(res.type).toBe('CallExpression');
|
|
289
|
-
expect(res.callee.name).toBe('e');
|
|
290
|
-
});
|
|
291
|
-
it('uses the element function when container has a slot ref', () => {
|
|
292
|
-
const container = Object.assign({}, complexDoc.compositions[0].compositions[2].compositions[0]);
|
|
293
|
-
container.slot = 'test';
|
|
294
|
-
const res = (0, compositionAstGeneration_1.containerToExpression)(moduleMetadata, container);
|
|
295
|
-
expect(res.type).toBe('CallExpression');
|
|
296
|
-
expect(res.callee.name).toBe('e');
|
|
297
|
-
});
|
|
298
|
-
it('returns first element when theres one child', () => {
|
|
299
|
-
const res = (0, compositionAstGeneration_1.containerToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[1].compositions[1]);
|
|
300
|
-
expect(res.type).toBe('CallExpression');
|
|
301
|
-
expect(res.callee.name).not.toBe('e');
|
|
302
|
-
});
|
|
303
|
-
it('returns an array element when there are multiple children', () => {
|
|
304
|
-
const res = (0, compositionAstGeneration_1.containerToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[2].compositions[1]);
|
|
305
|
-
expect(res.type).toBe('ArrayExpression');
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
describe('composedAdgToExpression', () => {
|
|
309
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
310
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata, 0);
|
|
311
|
-
it('properly composed composedAdg with no children', () => {
|
|
312
|
-
const res = (0, compositionAstGeneration_1.composedAdgToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[1].compositions[1]
|
|
313
|
-
.compositions[0]);
|
|
314
|
-
expect(res.type).toBe('CallExpression');
|
|
315
|
-
expect(res.callee.name).toBe('cg');
|
|
316
|
-
const code = (0, generator_1.default)(res).code;
|
|
317
|
-
expect(code).toBe('cg(i3, {\n componentId: "c-lookup-field-row",\n props: ctx => ({\n label: "CreatedBy User Info",\n objectApiName: "User",\n recordId: ctx.props.record?.data?.fields?.CreatedById?.value\n })\n}, ctx, [], ["record"])');
|
|
318
|
-
});
|
|
319
|
-
it('properly composed composedAdg with children', () => {
|
|
320
|
-
const res = (0, compositionAstGeneration_1.composedAdgToExpression)(moduleMetadata, complexDoc.compositions[0].compositions[0]);
|
|
321
|
-
expect(res.type).toBe('CallExpression');
|
|
322
|
-
expect(res.callee.name).toBe('cg');
|
|
323
|
-
const code = (0, generator_1.default)(res).code;
|
|
324
|
-
expect(code).toBe(`cg(i0, {
|
|
325
|
-
componentId: "lightning-card",
|
|
326
|
-
props: ctx => ({})
|
|
327
|
-
}, ctx, [cg(i1, {
|
|
328
|
-
slot: "title",
|
|
329
|
-
componentId: "c-title",
|
|
330
|
-
props: ctx => ({
|
|
331
|
-
icon: "standard:account",
|
|
332
|
-
size: "large"
|
|
333
|
-
})
|
|
334
|
-
}, ctx, [], []), c(ctx, {
|
|
335
|
-
c: {
|
|
336
|
-
t: "b",
|
|
337
|
-
v: "record.data"
|
|
338
|
-
},
|
|
339
|
-
slot: ""
|
|
340
|
-
}, ctx => [cg(i2, {
|
|
341
|
-
componentId: "c-fieldrow",
|
|
342
|
-
props: ctx => ({
|
|
343
|
-
label: "Object Type",
|
|
344
|
-
value: ctx.props.objectApiName
|
|
345
|
-
})
|
|
346
|
-
}, ctx, [], ["objectApiName"]), cg(i2, {
|
|
347
|
-
componentId: "c-fieldrow",
|
|
348
|
-
props: ctx => ({
|
|
349
|
-
label: "Account Id",
|
|
350
|
-
value: ctx.props.record?.data?.fields?.Id?.value
|
|
351
|
-
})
|
|
352
|
-
}, ctx, [], ["record"]), cg(i2, {
|
|
353
|
-
componentId: "c-fieldrow",
|
|
354
|
-
props: ctx => ({
|
|
355
|
-
label: "Account Name",
|
|
356
|
-
value: ctx.props.record?.data?.fields?.Name?.value
|
|
357
|
-
})
|
|
358
|
-
}, ctx, [], ["record"]), c(ctx, {
|
|
359
|
-
c: {
|
|
360
|
-
t: "b",
|
|
361
|
-
v: "ownerRecord.data"
|
|
362
|
-
}
|
|
363
|
-
}, ctx => cg(i2, {
|
|
364
|
-
componentId: "c-fieldrow",
|
|
365
|
-
props: ctx => ({
|
|
366
|
-
label: "Account Owner",
|
|
367
|
-
value: ctx.props.ownerRecord?.data?.fields?.Name?.value
|
|
368
|
-
})
|
|
369
|
-
}, ctx, [], ["ownerRecord"]), false), c(ctx, {
|
|
370
|
-
c: {
|
|
371
|
-
t: "b",
|
|
372
|
-
v: "createdByRecord.data"
|
|
373
|
-
}
|
|
374
|
-
}, ctx => cg(i2, {
|
|
375
|
-
componentId: "c-fieldrow",
|
|
376
|
-
props: ctx => ({
|
|
377
|
-
label: "Created By",
|
|
378
|
-
value: ctx.props.createdByRecord?.data?.fields?.Name?.value
|
|
379
|
-
})
|
|
380
|
-
}, ctx, [], ["createdByRecord"]), false)], false)], [])`);
|
|
381
|
-
});
|
|
382
|
-
it('properly generated dependentProps', () => {
|
|
383
|
-
const res = (0, compositionAstGeneration_1.composedAdgToExpression)(moduleMetadata, {
|
|
384
|
-
type: 'ComposedAdg',
|
|
385
|
-
input: {
|
|
386
|
-
type: 'ImportReference',
|
|
387
|
-
value: 't0-0/names/0',
|
|
388
|
-
},
|
|
389
|
-
properties: {
|
|
390
|
-
attr1: {
|
|
391
|
-
type: 'Binding',
|
|
392
|
-
value: 'recordId',
|
|
393
|
-
},
|
|
394
|
-
attr2: {
|
|
395
|
-
type: 'Binding',
|
|
396
|
-
value: 'recordId',
|
|
397
|
-
},
|
|
398
|
-
attr3: {
|
|
399
|
-
type: 'Binding',
|
|
400
|
-
value: 'record',
|
|
401
|
-
},
|
|
402
|
-
attr4: {
|
|
403
|
-
type: 'Binding',
|
|
404
|
-
value: 'record/data/Name',
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
});
|
|
408
|
-
expect(res.type).toBe('CallExpression');
|
|
409
|
-
expect(res.callee.name).toBe('cg');
|
|
410
|
-
const code = (0, generator_1.default)(res).code;
|
|
411
|
-
expect(code).toBe(`cg(i0, {
|
|
412
|
-
componentId: "lightning-card",
|
|
413
|
-
props: ctx => ({
|
|
414
|
-
attr1: ctx.props.recordId,
|
|
415
|
-
attr2: ctx.props.recordId,
|
|
416
|
-
attr3: ctx.props.record,
|
|
417
|
-
attr4: ctx.props.record?.data?.Name
|
|
418
|
-
})
|
|
419
|
-
}, ctx, [], ["recordId", "record"])`);
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
describe('iterationToExpression', () => {
|
|
423
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
424
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata, 0);
|
|
425
|
-
it('can compose an iteration factory call from a iterator composition', () => {
|
|
426
|
-
const res = (0, compositionAstGeneration_1.iterationToExpression)(moduleMetadata, {
|
|
427
|
-
type: 'Iteration',
|
|
428
|
-
input: {
|
|
429
|
-
type: 'Binding',
|
|
430
|
-
value: 'contacts',
|
|
431
|
-
},
|
|
432
|
-
iterator: 'contact',
|
|
433
|
-
compositions: [
|
|
434
|
-
{
|
|
435
|
-
type: 'ComposedAdg',
|
|
436
|
-
input: {
|
|
437
|
-
type: 'ImportReference',
|
|
438
|
-
value: 't0-0/names/0',
|
|
439
|
-
},
|
|
440
|
-
properties: {
|
|
441
|
-
label: {
|
|
442
|
-
type: 'Binding',
|
|
443
|
-
value: 'contact/value/Name',
|
|
444
|
-
},
|
|
445
|
-
myIndex: {
|
|
446
|
-
type: 'Binding',
|
|
447
|
-
value: 'contact/index',
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
key: {
|
|
451
|
-
type: 'Binding',
|
|
452
|
-
value: 'contact/value/Id',
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
],
|
|
456
|
-
});
|
|
457
|
-
expect(res.type).toBe('CallExpression');
|
|
458
|
-
expect(res.callee.name).toBe('i');
|
|
459
|
-
const code = (0, generator_1.default)(res).code;
|
|
460
|
-
expect(code).toBe(`i({
|
|
461
|
-
c: {
|
|
462
|
-
t: "b",
|
|
463
|
-
v: "contacts"
|
|
464
|
-
}
|
|
465
|
-
}, ctx, user_var_contact => {
|
|
466
|
-
return [cg(i0, {
|
|
467
|
-
componentId: "lightning-card",
|
|
468
|
-
props: ctx => ({
|
|
469
|
-
label: user_var_contact.value?.Name,
|
|
470
|
-
myIndex: user_var_contact.index
|
|
471
|
-
})
|
|
472
|
-
}, ctx, [], [])];
|
|
473
|
-
})`);
|
|
474
|
-
});
|
|
475
|
-
it('can compose an iteration factory call from a two nested iterator composition', () => {
|
|
476
|
-
const res = (0, compositionAstGeneration_1.iterationToExpression)(moduleMetadata, {
|
|
477
|
-
type: 'Iteration',
|
|
478
|
-
input: {
|
|
479
|
-
type: 'Binding',
|
|
480
|
-
value: 'contacts',
|
|
481
|
-
},
|
|
482
|
-
iterator: 'contact',
|
|
483
|
-
compositions: [
|
|
484
|
-
{
|
|
485
|
-
type: 'Iteration',
|
|
486
|
-
input: {
|
|
487
|
-
type: 'Binding',
|
|
488
|
-
value: 'actions',
|
|
489
|
-
},
|
|
490
|
-
iterator: 'action',
|
|
491
|
-
compositions: [
|
|
492
|
-
{
|
|
493
|
-
type: 'ComposedAdg',
|
|
494
|
-
input: {
|
|
495
|
-
type: 'ImportReference',
|
|
496
|
-
value: 't0-0/names/0',
|
|
497
|
-
},
|
|
498
|
-
properties: {
|
|
499
|
-
label: {
|
|
500
|
-
type: 'Binding',
|
|
501
|
-
value: 'contact/value/Name',
|
|
502
|
-
},
|
|
503
|
-
myIndex: {
|
|
504
|
-
type: 'Binding',
|
|
505
|
-
value: 'contact/index',
|
|
506
|
-
},
|
|
507
|
-
actionName: {
|
|
508
|
-
type: 'Binding',
|
|
509
|
-
value: 'action/name',
|
|
510
|
-
},
|
|
511
|
-
},
|
|
512
|
-
key: {
|
|
513
|
-
type: 'Binding',
|
|
514
|
-
value: 'contact/value/Id',
|
|
515
|
-
},
|
|
516
|
-
},
|
|
517
|
-
],
|
|
518
|
-
},
|
|
519
|
-
],
|
|
520
|
-
});
|
|
521
|
-
expect(res.type).toBe('CallExpression');
|
|
522
|
-
expect(res.callee.name).toBe('i');
|
|
523
|
-
const code = (0, generator_1.default)(res).code;
|
|
524
|
-
expect(code).toBe(`i({
|
|
525
|
-
c: {
|
|
526
|
-
t: "b",
|
|
527
|
-
v: "contacts"
|
|
528
|
-
}
|
|
529
|
-
}, ctx, user_var_contact => {
|
|
530
|
-
return [i({
|
|
531
|
-
c: {
|
|
532
|
-
t: "b",
|
|
533
|
-
v: "actions"
|
|
534
|
-
}
|
|
535
|
-
}, ctx, user_var_action => {
|
|
536
|
-
return [cg(i0, {
|
|
537
|
-
componentId: "lightning-card",
|
|
538
|
-
props: ctx => ({
|
|
539
|
-
actionName: user_var_action.name,
|
|
540
|
-
label: user_var_contact.value?.Name,
|
|
541
|
-
myIndex: user_var_contact.index
|
|
542
|
-
})
|
|
543
|
-
}, ctx, [], [])];
|
|
544
|
-
})];
|
|
545
|
-
})`);
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
describe('slotToExpression', () => {
|
|
549
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
550
|
-
(0, common_shared_1.initializeImportMetdataFromKomaciDocument)(complexDoc, moduleMetadata);
|
|
551
|
-
it('can compose a slot factory call from a iterator composition', () => {
|
|
552
|
-
const res = (0, compositionAstGeneration_1.slotToExpression)(moduleMetadata, {
|
|
553
|
-
type: 'Slot',
|
|
554
|
-
name: 'full-name',
|
|
555
|
-
compositions: [
|
|
556
|
-
{
|
|
557
|
-
type: 'Slot',
|
|
558
|
-
name: 'first-name',
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
type: 'Slot',
|
|
562
|
-
name: 'last-name',
|
|
563
|
-
},
|
|
564
|
-
],
|
|
565
|
-
});
|
|
566
|
-
expect(res.type).toBe('CallExpression');
|
|
567
|
-
expect(res.callee.name).toBe('s');
|
|
568
|
-
const code = (0, generator_1.default)(res).code;
|
|
569
|
-
expect(code).toBe('s("full-name", {}, ctx, [s("first-name", {}, ctx), s("last-name", {}, ctx)])');
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
describe('getCompositionConfig', () => {
|
|
573
|
-
it('collects composition config for a container', () => {
|
|
574
|
-
const res = (0, compositionAstGeneration_1.getCompositionConfig)({
|
|
575
|
-
type: 'Container',
|
|
576
|
-
isActive: {
|
|
577
|
-
input: {
|
|
578
|
-
type: 'Binding',
|
|
579
|
-
value: 'fukuoka',
|
|
580
|
-
},
|
|
581
|
-
negate: false,
|
|
582
|
-
},
|
|
583
|
-
compositions: [
|
|
584
|
-
{
|
|
585
|
-
type: 'Slot',
|
|
586
|
-
name: '',
|
|
587
|
-
},
|
|
588
|
-
],
|
|
589
|
-
});
|
|
590
|
-
const code = (0, generator_1.default)(res).code;
|
|
591
|
-
expect(code).toBe('{}');
|
|
592
|
-
});
|
|
593
|
-
it('collects composition config for a composedAdg', () => {
|
|
594
|
-
const res = (0, compositionAstGeneration_1.getCompositionConfig)(complexDoc.compositions[0].compositions[2].compositions[0]);
|
|
595
|
-
const code = (0, generator_1.default)(res).code;
|
|
596
|
-
expect(code).toBe('{\n slot: "title",\n props: ctx => ({\n icon: "standard:apex",\n size: "medium"\n })\n}');
|
|
597
|
-
});
|
|
598
|
-
it('generates duplicate composition configs for similar composedAdgs', () => {
|
|
599
|
-
const res = (0, compositionAstGeneration_1.getCompositionConfig)(complexDoc.compositions[0].compositions[2].compositions[0]);
|
|
600
|
-
// generate config for composedAdg that is identical apart from ordering of props
|
|
601
|
-
const swapRes = (0, compositionAstGeneration_1.getCompositionConfig)({
|
|
602
|
-
type: 'ComposedAdg',
|
|
603
|
-
input: {
|
|
604
|
-
type: 'ImportReference',
|
|
605
|
-
value: '1names/0',
|
|
606
|
-
},
|
|
607
|
-
properties: {
|
|
608
|
-
icon: {
|
|
609
|
-
type: 'PrimitiveValue',
|
|
610
|
-
value: 'standard:apex',
|
|
611
|
-
},
|
|
612
|
-
size: {
|
|
613
|
-
type: 'PrimitiveValue',
|
|
614
|
-
value: 'medium',
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
slot: 'title',
|
|
618
|
-
});
|
|
619
|
-
const swappedCode = (0, generator_1.default)(swapRes).code;
|
|
620
|
-
const code = (0, generator_1.default)(res).code;
|
|
621
|
-
const expected = '{\n slot: "title",\n props: ctx => ({\n icon: "standard:apex",\n size: "medium"\n })\n}';
|
|
622
|
-
expect(code).toBe(expected);
|
|
623
|
-
expect(swappedCode).toBe(expected);
|
|
624
|
-
});
|
|
625
|
-
it('collects composition config for a slot', () => {
|
|
626
|
-
const res = (0, compositionAstGeneration_1.getCompositionConfig)({
|
|
627
|
-
type: 'Slot',
|
|
628
|
-
name: 'full-name',
|
|
629
|
-
compositions: [
|
|
630
|
-
{
|
|
631
|
-
type: 'Slot',
|
|
632
|
-
name: 'first-name',
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
type: 'Slot',
|
|
636
|
-
name: 'last-name',
|
|
637
|
-
},
|
|
638
|
-
],
|
|
639
|
-
});
|
|
640
|
-
const code = (0, generator_1.default)(res).code;
|
|
641
|
-
expect(code).toBe('{}');
|
|
642
|
-
});
|
|
643
|
-
it('can handle a prop name having special characters', () => {
|
|
644
|
-
const res = (0, compositionAstGeneration_1.getCompositionConfig)({
|
|
645
|
-
type: 'ComposedAdg',
|
|
646
|
-
input: {
|
|
647
|
-
type: 'ImportReference',
|
|
648
|
-
value: '0/names/0',
|
|
649
|
-
},
|
|
650
|
-
properties: {
|
|
651
|
-
'foo:baz': {
|
|
652
|
-
type: 'PrimitiveValue',
|
|
653
|
-
value: 'bar',
|
|
654
|
-
},
|
|
655
|
-
'baz:foo': {
|
|
656
|
-
type: 'Binding',
|
|
657
|
-
value: 'bar',
|
|
658
|
-
},
|
|
659
|
-
baz: {
|
|
660
|
-
type: 'Binding',
|
|
661
|
-
value: 'bar',
|
|
662
|
-
},
|
|
663
|
-
foo: {
|
|
664
|
-
type: 'PrimitiveValue',
|
|
665
|
-
value: 'bar',
|
|
666
|
-
},
|
|
667
|
-
},
|
|
668
|
-
});
|
|
669
|
-
const functionBody = res.properties[0].value.body;
|
|
670
|
-
expect(functionBody.properties[0].key.type).toBe('Identifier');
|
|
671
|
-
expect(functionBody.properties[1].key.type).toBe('StringLiteral');
|
|
672
|
-
expect(functionBody.properties[2].key.type).toBe('Identifier');
|
|
673
|
-
expect(functionBody.properties[3].key.type).toBe('StringLiteral');
|
|
674
|
-
});
|
|
675
|
-
});
|
|
676
|
-
//# sourceMappingURL=compositionAstGeneration.spec.js.map
|