@squiz/dx-common-lib 1.53.1-alpha.2 → 1.53.1-alpha.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildFontClasses = exports.buildAttributesString = exports.formattedTextToHtmlString = exports.formattedTextToHtmlStringResolvers = void 0;
4
- const dx_json_schema_lib_1 = require("@squiz/dx-json-schema-lib");
5
- const error_1 = require("../error");
6
- exports.formattedTextToHtmlStringResolvers = {
7
- tag: async (node) => buildTagHTML(node),
8
- text: async (node) => node.value,
9
- component: async (node) => {
10
- return buildComponentHtml(node);
11
- },
12
- default: async (node) => {
13
- return `<p class="invalid-node-type"> node of type "${node.type}" cannot be converted to html</p>`;
14
- },
15
- };
16
- async function formattedTextToHtmlString(formattedText) {
17
- const output = await (0, dx_json_schema_lib_1.resolveFormattedText)(formattedText, exports.formattedTextToHtmlStringResolvers);
18
- return output;
19
- }
20
- exports.formattedTextToHtmlString = formattedTextToHtmlString;
21
- function buildTagHTML(formattedTextTag) {
22
- const classes = getClassString(formattedTextTag);
23
- if (!formattedTextTag.attributes) {
24
- formattedTextTag.attributes = { class: classes };
25
- }
26
- else {
27
- formattedTextTag.attributes.class = classes;
28
- }
29
- const attributesStr = buildAttributesString(formattedTextTag.attributes);
30
- return `<${formattedTextTag.tag}${attributesStr}>${formattedTextTag.children.join('')}</${formattedTextTag.tag}>`;
31
- }
32
- function buildComponentHtml(node) {
33
- const esiUrl = buildComponentRenderEsiUrl(node);
34
- const esiTag = `<esi:include src="${esiUrl}"/>`;
35
- return esiTag;
36
- }
37
- function getClassString(formattedTextTag) {
38
- var _a, _b, _c;
39
- const fontClasses = buildFontClasses(formattedTextTag.font);
40
- let string = (_b = (_a = formattedTextTag === null || formattedTextTag === void 0 ? void 0 : formattedTextTag.attributes) === null || _a === void 0 ? void 0 : _a.class) !== null && _b !== void 0 ? _b : '';
41
- if ((_c = formattedTextTag === null || formattedTextTag === void 0 ? void 0 : formattedTextTag.formattingOptions) === null || _c === void 0 ? void 0 : _c.alignment) {
42
- fontClasses.push(formattedTextTag.formattingOptions.alignment);
43
- }
44
- if (fontClasses.length > 0) {
45
- string += ' ' + fontClasses.join(' ');
46
- }
47
- return string.trim();
48
- }
49
- function buildAttributesString(attributes) {
50
- if (!attributes) {
51
- return '';
52
- }
53
- let attributesString = '';
54
- for (const attribute in attributes) {
55
- if (attributes[attribute] !== '') {
56
- attributesString += ` ${attribute}="${attributes[attribute]}"`;
57
- }
58
- }
59
- return attributesString;
60
- }
61
- exports.buildAttributesString = buildAttributesString;
62
- function buildFontClasses(font) {
63
- if (!font) {
64
- return [];
65
- }
66
- const classes = [];
67
- if (font.bold) {
68
- classes.push('bold');
69
- }
70
- if (font.underline) {
71
- classes.push('underline');
72
- }
73
- if (font.italics) {
74
- classes.push('italics');
75
- }
76
- if (font.color) {
77
- classes.push(`color-${font.color}`);
78
- }
79
- if (font.size) {
80
- classes.push(`size-${font.size}`);
81
- }
82
- if (font.fontFamily) {
83
- classes.push(`font-${font.fontFamily}`);
84
- }
85
- return classes;
86
- }
87
- exports.buildFontClasses = buildFontClasses;
88
- function buildComponentRenderEsiUrl(node) {
89
- var _a;
90
- const BASE_DXP_PATH = '/__dxp/au/components-render';
91
- if (process.env.TENANT_ID === undefined) {
92
- throw new error_1.InternalServerError('component node resolution failed due to unknown tenant');
93
- }
94
- const tenantId = process.env.TENANT_ID;
95
- let query = `?_componentSet=${node.componentSet}`;
96
- if ((_a = node.contentItem) === null || _a === void 0 ? void 0 : _a.id) {
97
- query = query.concat(`&_contentItemId=${node.contentItem.id}`);
98
- }
99
- return `${BASE_DXP_PATH}/${tenantId}/r/${node.componentId}${query}`;
100
- }
101
- //# sourceMappingURL=formattedTextToHtmlString.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formattedTextToHtmlString.js","sourceRoot":"","sources":["../../src/formatted-text/formattedTextToHtmlString.ts"],"names":[],"mappings":";;;AAAA,kEAOmC;AACnC,oCAA+C;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AClB,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC3B;IACD,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACzB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;KACrC;IACD,IAAI,IAAI,CAAC,IAAI,EAAE;QACb,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KACnC;IACD,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;KACzC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA1BD,4CA0BC;AAED,SAAS,0BAA0B,CAAC,IAAmB;;IACrD,MAAM,aAAa,GAAG,6BAA6B,CAAC;IAEpD,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE;QACvC,MAAM,IAAI,2BAAmB,CAAC,wDAAwD,CAAC,CAAC;KACzF;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAEvC,IAAI,KAAK,GAAG,kBAAkB,IAAI,CAAC,YAAY,EAAE,CAAC;IAClD,IAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,EAAE,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;KAChE;IAED,OAAO,GAAG,aAAa,IAAI,QAAQ,MAAM,IAAI,CAAC,WAAW,GAAG,KAAK,EAAE,CAAC;AACtE,CAAC"}
@@ -1,261 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const formattedTextToHtmlString_1 = require("./formattedTextToHtmlString");
4
- const BASE_DXP_PATH = '/__dxp/au/components-render';
5
- const TEST_TENANT = 'TENANT_ID';
6
- describe('formattedTextToHtmlString', () => {
7
- const env = process.env;
8
- beforeEach(() => {
9
- jest.resetModules();
10
- process.env = { ...env };
11
- process.env.TENANT_ID = TEST_TENANT;
12
- });
13
- afterEach(() => {
14
- process.env = env;
15
- });
16
- it('should convert text nodes to HTML', async () => {
17
- const textNode = {
18
- type: 'text',
19
- value: 'Hello, world!',
20
- };
21
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(textNode)).resolves.toBe('Hello, world!');
22
- });
23
- it('should convert tag nodes to HTML', async () => {
24
- const tagNode = {
25
- type: 'tag',
26
- tag: 'p',
27
- children: [{ type: 'text', value: 'Hello, world!' }],
28
- };
29
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(tagNode)).resolves.toBe('<p>Hello, world!</p>');
30
- });
31
- it('should convert tag nodes with attributes to HTML', async () => {
32
- const tagNode = {
33
- type: 'tag',
34
- tag: 'p',
35
- attributes: {
36
- id: 'hello-world',
37
- class: 'greeting',
38
- },
39
- children: [{ type: 'text', value: 'Hello, world!' }],
40
- };
41
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(tagNode)).resolves.toBe('<p id="hello-world" class="greeting">Hello, world!</p>');
42
- });
43
- it('should convert tag nodes with font properties to HTML', async () => {
44
- const tagNode = {
45
- type: 'tag',
46
- tag: 'p',
47
- font: {
48
- bold: true,
49
- underline: true,
50
- italics: false,
51
- color: 'red',
52
- size: 'large',
53
- fontFamily: 'Arial',
54
- },
55
- children: [{ type: 'text', value: 'Hello, world!' }],
56
- };
57
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(tagNode)).resolves.toBe('<p class="bold underline color-red size-large font-Arial">Hello, world!</p>');
58
- });
59
- it('converts a tag node with attributes but no children to html', async () => {
60
- const node = {
61
- type: 'tag',
62
- tag: 'p',
63
- children: [],
64
- attributes: { class: 'test-class' },
65
- };
66
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(node)).resolves.toEqual('<p class="test-class"></p>');
67
- });
68
- it('converts a tag node with children but no attributes to html', async () => {
69
- const node = {
70
- type: 'tag',
71
- tag: 'p',
72
- children: [
73
- { type: 'text', value: 'This is a test' },
74
- { type: 'text', value: 'This is another test' },
75
- ],
76
- };
77
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(node)).resolves.toEqual('<p>This is a testThis is another test</p>');
78
- });
79
- it('converts a tag node with children and attributes to html', async () => {
80
- const node = {
81
- type: 'tag',
82
- tag: 'p',
83
- attributes: { class: 'test-class' },
84
- children: [
85
- { type: 'text', value: 'This is a test' },
86
- { type: 'text', value: 'This is another test' },
87
- ],
88
- };
89
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(node)).resolves.toEqual('<p class="test-class">This is a testThis is another test</p>');
90
- });
91
- it('should convert a tag node with attributes to HTML', async () => {
92
- const input = {
93
- type: 'tag',
94
- tag: 'div',
95
- children: [],
96
- attributes: {
97
- id: 'my-div',
98
- 'data-foo': 'bar',
99
- },
100
- };
101
- const expectedOutput = '<div id="my-div" data-foo="bar"></div>';
102
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(input)).resolves.toEqual(expectedOutput);
103
- });
104
- it('should add the correct class for left alignment', async () => {
105
- const formattedNode = {
106
- type: 'tag',
107
- children: [],
108
- tag: 'p',
109
- formattingOptions: {
110
- alignment: 'left',
111
- },
112
- };
113
- const html = (0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNode);
114
- await expect(html).resolves.toEqual('<p class="left"></p>');
115
- });
116
- it('should add the correct class for right alignment', async () => {
117
- const formattedNode = {
118
- type: 'tag',
119
- children: [],
120
- tag: 'p',
121
- formattingOptions: {
122
- alignment: 'right',
123
- },
124
- };
125
- const html = (0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNode);
126
- await expect(html).resolves.toEqual('<p class="right"></p>');
127
- });
128
- it('should add the correct class for center alignment', async () => {
129
- const formattedNode = {
130
- type: 'tag',
131
- children: [],
132
- tag: 'p',
133
- formattingOptions: {
134
- alignment: 'center',
135
- },
136
- };
137
- const html = (0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNode);
138
- await expect(html).resolves.toEqual('<p class="center"></p>');
139
- });
140
- it('should add the correct class for justify alignment', async () => {
141
- const formattedNode = {
142
- type: 'tag',
143
- children: [],
144
- tag: 'p',
145
- formattingOptions: {
146
- alignment: 'justify',
147
- },
148
- };
149
- const html = (0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNode);
150
- await expect(html).resolves.toEqual('<p class="justify"></p>');
151
- });
152
- it('should handle input with formattingOptions, font and class attributes', async () => {
153
- const formattedTextTag = {
154
- type: 'tag',
155
- tag: 'p',
156
- formattingOptions: {
157
- alignment: 'center',
158
- },
159
- font: {
160
- bold: true,
161
- color: 'red',
162
- },
163
- attributes: {
164
- class: 'my-class',
165
- },
166
- children: [
167
- {
168
- type: 'text',
169
- value: 'Hello, World!',
170
- },
171
- ],
172
- };
173
- const expectedResult = '<p class="my-class bold color-red center">Hello, World!</p>';
174
- const result = (0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedTextTag);
175
- await expect(result).resolves.toBe(expectedResult);
176
- });
177
- it('should return an error message for an unknown node type', async () => {
178
- const formattedNodes = {
179
- type: 'unknown',
180
- value: 'Hello World!',
181
- };
182
- const expectedHTML = `<p class="invalid-node-type"> node of type "unknown" cannot be converted to html</p>`;
183
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNodes)).resolves.toEqual(expectedHTML);
184
- });
185
- it('should handle deeply nested FormattedNodes object', async () => {
186
- const formattedNodes = {
187
- type: 'tag',
188
- tag: 'div',
189
- formattingOptions: {
190
- alignment: 'justify',
191
- },
192
- children: [
193
- {
194
- type: 'text',
195
- value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
196
- },
197
- {
198
- type: 'tag',
199
- tag: 'strong',
200
- font: {
201
- bold: true,
202
- },
203
- children: [
204
- {
205
- type: 'text',
206
- value: 'Vestibulum',
207
- },
208
- {
209
- type: 'text',
210
- value: ' dictum',
211
- },
212
- ],
213
- },
214
- {
215
- type: 'text',
216
- value: ' mi vel urna maximus, et luctus ipsum tincidunt',
217
- },
218
- ],
219
- };
220
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNodes)).resolves.toMatchInlineSnapshot(`"<div class="justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <strong class="bold">Vestibulum dictum</strong> mi vel urna maximus, et luctus ipsum tincidunt</div>"`);
221
- });
222
- it('should return the correct esi tag for component render', async () => {
223
- var _a;
224
- const formattedNodes = {
225
- type: 'component',
226
- componentSet: 'test',
227
- contentItem: {
228
- id: '123',
229
- },
230
- componentId: 'page-demo/demo-button/1.0.0',
231
- };
232
- const expectedEsiTag = `<esi:include src="${BASE_DXP_PATH}/${TEST_TENANT}/r/${formattedNodes.componentId}?_componentSet=test&_contentItemId=${(_a = formattedNodes.contentItem) === null || _a === void 0 ? void 0 : _a.id}"/>`;
233
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNodes)).resolves.toEqual(expectedEsiTag);
234
- });
235
- it('should return the correct esi tag when there is no content item on the component node', async () => {
236
- var _a;
237
- const formattedNodes = {
238
- type: 'component',
239
- componentSet: 'test',
240
- contentItem: {
241
- id: '123',
242
- },
243
- componentId: 'page-demo/demo-button/1.0.0',
244
- };
245
- const expectedEsiTag = `<esi:include src="${BASE_DXP_PATH}/${TEST_TENANT}/r/${formattedNodes.componentId}?_componentSet=test&_contentItemId=${(_a = formattedNodes.contentItem) === null || _a === void 0 ? void 0 : _a.id}"/>`;
246
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNodes)).resolves.toEqual(expectedEsiTag);
247
- });
248
- it('should throw an error if tenant_id is not defined', async () => {
249
- delete process.env.TENANT_ID;
250
- const formattedNodes = {
251
- type: 'component',
252
- componentSet: 'test',
253
- contentItem: {
254
- id: '123',
255
- },
256
- componentId: 'page-demo/demo-button/1.0.0',
257
- };
258
- await expect((0, formattedTextToHtmlString_1.formattedTextToHtmlString)(formattedNodes)).rejects.toThrowErrorMatchingInlineSnapshot(`"component node resolution failed due to unknown tenant"`);
259
- });
260
- });
261
- //# sourceMappingURL=formattedTextToHtmlString.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formattedTextToHtmlString.spec.js","sourceRoot":"","sources":["../../src/formatted-text/formattedTextToHtmlString.spec.ts"],"names":[],"mappings":";;AACA,2EAAwE;AAIxE,MAAM,aAAa,GAAG,6BAA6B,CAAC;AACpD,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAExB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,QAAQ,GAAmB;YAC/B,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,eAAe;SACvB,CAAC;QACF,MAAM,MAAM,CAAC,IAAA,qDAAyB,EAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,OAAO,GAAmB;YAC9B,IAAI,EAAE,KAAK;YACX,GAAG,EAAE,GAAG;YACR,QAAQ,EAAE,CAAC,EA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@ -1,294 +0,0 @@
1
- import { BaseResolvedNodes } from '@squiz/dx-json-schema-lib';
2
- import { formattedTextToHtmlString } from './formattedTextToHtmlString';
3
-
4
- type FormattedNodes = BaseResolvedNodes;
5
- type FormattedTextTag = BaseResolvedNodes & { type: 'tag' };
6
- const BASE_DXP_PATH = '/__dxp/au/components-render';
7
- const TEST_TENANT = 'TENANT_ID';
8
-
9
- describe('formattedTextToHtmlString', () => {
10
- const env = process.env;
11
-
12
- beforeEach(() => {
13
- jest.resetModules();
14
- process.env = { ...env };
15
- process.env.TENANT_ID = TEST_TENANT;
16
- });
17
-
18
- afterEach(() => {
19
- process.env = env;
20
- });
21
-
22
- it('should convert text nodes to HTML', async () => {
23
- const textNode: FormattedNodes = {
24
- type: 'text',
25
- value: 'Hello, world!',
26
- };
27
- await expect(formattedTextToHtmlString(textNode)).resolves.toBe('Hello, world!');
28
- });
29
-
30
- it('should convert tag nodes to HTML', async () => {
31
- const tagNode: FormattedNodes = {
32
- type: 'tag',
33
- tag: 'p',
34
- children: [{ type: 'text', value: 'Hello, world!' }],
35
- };
36
- await expect(formattedTextToHtmlString(tagNode)).resolves.toBe('<p>Hello, world!</p>');
37
- });
38
-
39
- it('should convert tag nodes with attributes to HTML', async () => {
40
- const tagNode: FormattedNodes = {
41
- type: 'tag',
42
- tag: 'p',
43
- attributes: {
44
- id: 'hello-world',
45
- class: 'greeting',
46
- },
47
- children: [{ type: 'text', value: 'Hello, world!' }],
48
- };
49
- await expect(formattedTextToHtmlString(tagNode)).resolves.toBe(
50
- '<p id="hello-world" class="greeting">Hello, world!</p>',
51
- );
52
- });
53
-
54
- it('should convert tag nodes with font properties to HTML', async () => {
55
- const tagNode: FormattedNodes = {
56
- type: 'tag',
57
- tag: 'p',
58
- font: {
59
- bold: true,
60
- underline: true,
61
- italics: false,
62
- color: 'red',
63
- size: 'large',
64
- fontFamily: 'Arial',
65
- },
66
- children: [{ type: 'text', value: 'Hello, world!' }],
67
- };
68
- await expect(formattedTextToHtmlString(tagNode)).resolves.toBe(
69
- '<p class="bold underline color-red size-large font-Arial">Hello, world!</p>',
70
- );
71
- });
72
-
73
- it('converts a tag node with attributes but no children to html', async () => {
74
- const node: FormattedNodes = {
75
- type: 'tag',
76
- tag: 'p',
77
- children: [],
78
- attributes: { class: 'test-class' },
79
- };
80
- await expect(formattedTextToHtmlString(node)).resolves.toEqual('<p class="test-class"></p>');
81
- });
82
-
83
- it('converts a tag node with children but no attributes to html', async () => {
84
- const node: FormattedNodes = {
85
- type: 'tag',
86
- tag: 'p',
87
- children: [
88
- { type: 'text', value: 'This is a test' },
89
- { type: 'text', value: 'This is another test' },
90
- ],
91
- };
92
- await expect(formattedTextToHtmlString(node)).resolves.toEqual('<p>This is a testThis is another test</p>');
93
- });
94
-
95
- it('converts a tag node with children and attributes to html', async () => {
96
- const node: FormattedNodes = {
97
- type: 'tag',
98
- tag: 'p',
99
- attributes: { class: 'test-class' },
100
- children: [
101
- { type: 'text', value: 'This is a test' },
102
- { type: 'text', value: 'This is another test' },
103
- ],
104
- };
105
- await expect(formattedTextToHtmlString(node)).resolves.toEqual(
106
- '<p class="test-class">This is a testThis is another test</p>',
107
- );
108
- });
109
-
110
- it('should convert a tag node with attributes to HTML', async () => {
111
- const input: FormattedNodes = {
112
- type: 'tag',
113
- tag: 'div',
114
- children: [],
115
- attributes: {
116
- id: 'my-div',
117
- 'data-foo': 'bar',
118
- },
119
- };
120
- const expectedOutput = '<div id="my-div" data-foo="bar"></div>';
121
- await expect(formattedTextToHtmlString(input)).resolves.toEqual(expectedOutput);
122
- });
123
-
124
- it('should add the correct class for left alignment', async () => {
125
- const formattedNode: FormattedTextTag = {
126
- type: 'tag',
127
- children: [],
128
- tag: 'p',
129
- formattingOptions: {
130
- alignment: 'left',
131
- },
132
- };
133
- const html = formattedTextToHtmlString(formattedNode);
134
- await expect(html).resolves.toEqual('<p class="left"></p>');
135
- });
136
-
137
- it('should add the correct class for right alignment', async () => {
138
- const formattedNode: FormattedTextTag = {
139
- type: 'tag',
140
- children: [],
141
- tag: 'p',
142
- formattingOptions: {
143
- alignment: 'right',
144
- },
145
- };
146
- const html = formattedTextToHtmlString(formattedNode);
147
- await expect(html).resolves.toEqual('<p class="right"></p>');
148
- });
149
-
150
- it('should add the correct class for center alignment', async () => {
151
- const formattedNode: FormattedTextTag = {
152
- type: 'tag',
153
- children: [],
154
- tag: 'p',
155
- formattingOptions: {
156
- alignment: 'center',
157
- },
158
- };
159
- const html = formattedTextToHtmlString(formattedNode);
160
- await expect(html).resolves.toEqual('<p class="center"></p>');
161
- });
162
-
163
- it('should add the correct class for justify alignment', async () => {
164
- const formattedNode: FormattedTextTag = {
165
- type: 'tag',
166
- children: [],
167
- tag: 'p',
168
- formattingOptions: {
169
- alignment: 'justify',
170
- },
171
- };
172
- const html = formattedTextToHtmlString(formattedNode);
173
- await expect(html).resolves.toEqual('<p class="justify"></p>');
174
- });
175
-
176
- it('should handle input with formattingOptions, font and class attributes', async () => {
177
- const formattedTextTag: FormattedTextTag = {
178
- type: 'tag',
179
- tag: 'p',
180
- formattingOptions: {
181
- alignment: 'center',
182
- },
183
- font: {
184
- bold: true,
185
- color: 'red',
186
- },
187
- attributes: {
188
- class: 'my-class',
189
- },
190
- children: [
191
- {
192
- type: 'text',
193
- value: 'Hello, World!',
194
- },
195
- ],
196
- };
197
-
198
- const expectedResult = '<p class="my-class bold color-red center">Hello, World!</p>';
199
-
200
- const result = formattedTextToHtmlString(formattedTextTag);
201
- await expect(result).resolves.toBe(expectedResult);
202
- });
203
-
204
- it('should return an error message for an unknown node type', async () => {
205
- const formattedNodes: FormattedNodes = {
206
- type: 'unknown' as any,
207
- value: 'Hello World!',
208
- };
209
- const expectedHTML = `<p class="invalid-node-type"> node of type "unknown" cannot be converted to html</p>`;
210
- await expect(formattedTextToHtmlString(formattedNodes)).resolves.toEqual(expectedHTML);
211
- });
212
-
213
- it('should handle deeply nested FormattedNodes object', async () => {
214
- const formattedNodes: FormattedNodes = {
215
- type: 'tag',
216
- tag: 'div',
217
- formattingOptions: {
218
- alignment: 'justify',
219
- },
220
- children: [
221
- {
222
- type: 'text',
223
- value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
224
- },
225
- {
226
- type: 'tag',
227
- tag: 'strong',
228
- font: {
229
- bold: true,
230
- },
231
- children: [
232
- {
233
- type: 'text',
234
- value: 'Vestibulum',
235
- },
236
- {
237
- type: 'text',
238
- value: ' dictum',
239
- },
240
- ],
241
- },
242
- {
243
- type: 'text',
244
- value: ' mi vel urna maximus, et luctus ipsum tincidunt',
245
- },
246
- ],
247
- };
248
-
249
- await expect(formattedTextToHtmlString(formattedNodes)).resolves.toMatchInlineSnapshot(
250
- `"<div class="justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <strong class="bold">Vestibulum dictum</strong> mi vel urna maximus, et luctus ipsum tincidunt</div>"`,
251
- );
252
- });
253
-
254
- it('should return the correct esi tag for component render', async () => {
255
- const formattedNodes: FormattedNodes = {
256
- type: 'component',
257
- componentSet: 'test',
258
- contentItem: {
259
- id: '123',
260
- },
261
- componentId: 'page-demo/demo-button/1.0.0',
262
- };
263
- const expectedEsiTag = `<esi:include src="${BASE_DXP_PATH}/${TEST_TENANT}/r/${formattedNodes.componentId}?_componentSet=test&_contentItemId=${formattedNodes.contentItem?.id}"/>`;
264
- await expect(formattedTextToHtmlString(formattedNodes)).resolves.toEqual(expectedEsiTag);
265
- });
266
-
267
- it('should return the correct esi tag when there is no content item on the component node', async () => {
268
- const formattedNodes: FormattedNodes = {
269
- type: 'component',
270
- componentSet: 'test',
271
- contentItem: {
272
- id: '123',
273
- },
274
- componentId: 'page-demo/demo-button/1.0.0',
275
- };
276
- const expectedEsiTag = `<esi:include src="${BASE_DXP_PATH}/${TEST_TENANT}/r/${formattedNodes.componentId}?_componentSet=test&_contentItemId=${formattedNodes.contentItem?.id}"/>`;
277
- await expect(formattedTextToHtmlString(formattedNodes)).resolves.toEqual(expectedEsiTag);
278
- });
279
-
280
- it('should throw an error if tenant_id is not defined', async () => {
281
- delete process.env.TENANT_ID;
282
- const formattedNodes: FormattedNodes = {
283
- type: 'component',
284
- componentSet: 'test',
285
- contentItem: {
286
- id: '123',
287
- },
288
- componentId: 'page-demo/demo-button/1.0.0',
289
- };
290
- await expect(formattedTextToHtmlString(formattedNodes)).rejects.toThrowErrorMatchingInlineSnapshot(
291
- `"component node resolution failed due to unknown tenant"`,
292
- );
293
- });
294
- });