@saltcorn/markup 1.6.1-beta.0 → 1.7.0-alpha.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/cjs/builder.cjs +10 -0
- package/cjs/layout.cjs +10 -0
- package/cjs/mktag.cjs +10 -0
- package/cjs/table.cjs +10 -0
- package/cjs/tabs.cjs +10 -0
- package/cjs/workflow.cjs +10 -0
- package/dist/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +13 -3
- package/dist/builder.js.map +1 -1
- package/dist/emergency_layout.d.ts +30 -3
- package/dist/emergency_layout.d.ts.map +1 -1
- package/dist/emergency_layout.js +5 -6
- package/dist/emergency_layout.js.map +1 -1
- package/dist/extra_tags.d.ts +31 -0
- package/dist/extra_tags.d.ts.map +1 -0
- package/dist/extra_tags.js +54 -0
- package/dist/extra_tags.js.map +1 -0
- package/dist/form.d.ts +21 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +13 -14
- package/dist/form.js.map +1 -1
- package/dist/form.test.js +48 -84
- package/dist/form.test.js.map +1 -1
- package/dist/generated_tags.d.ts +127 -0
- package/dist/generated_tags.d.ts.map +1 -0
- package/dist/generated_tags.js +253 -0
- package/dist/generated_tags.js.map +1 -0
- package/dist/helpers.d.ts +95 -53
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +3 -3
- package/dist/helpers.js.map +1 -1
- package/dist/helpers.test.js +123 -127
- package/dist/helpers.test.js.map +1 -1
- package/dist/index.d.ts +95 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +29 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +24 -10
- package/dist/internal.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +124 -97
- package/dist/layout.js.map +1 -1
- package/dist/layout.test.js +130 -167
- package/dist/layout.test.js.map +1 -1
- package/dist/layout_utils.d.ts +142 -2
- package/dist/layout_utils.d.ts.map +1 -1
- package/dist/layout_utils.js +7 -4
- package/dist/layout_utils.js.map +1 -1
- package/dist/layout_utils.test.js +49 -53
- package/dist/layout_utils.test.js.map +1 -1
- package/dist/markup.test.js +227 -264
- package/dist/markup.test.js.map +1 -1
- package/dist/mjml-layout.d.ts +31 -1
- package/dist/mjml-layout.d.ts.map +1 -1
- package/dist/mjml-layout.js +4 -4
- package/dist/mjml-layout.js.map +1 -1
- package/dist/mjml-tags.d.ts +40 -4
- package/dist/mjml-tags.d.ts.map +1 -1
- package/dist/mjml-tags.js +31 -21
- package/dist/mjml-tags.js.map +1 -1
- package/dist/mktag.d.ts +2 -2
- package/dist/mktag.d.ts.map +1 -1
- package/dist/mktag.js +1 -2
- package/dist/mktag.js.map +1 -1
- package/dist/table.d.ts +3 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +63 -16
- package/dist/table.js.map +1 -1
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +2 -3
- package/dist/tabs.js.map +1 -1
- package/dist/tags.d.ts +7 -2
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +16 -94
- package/dist/tags.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +2 -3
- package/dist/workflow.js.map +1 -1
- package/package.json +46 -12
- /package/{webpack.config.js → webpack.config.cjs} +0 -0
package/dist/layout.test.js
CHANGED
|
@@ -1,51 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const globals_1 = require("@jest/globals");
|
|
40
|
-
const layout_1 = __importDefault(require("./layout"));
|
|
41
|
-
// import { makeSegments, applyTextStyle, textStyleToArray } from "./internal";
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import { expect } from "@saltcorn/db-common/test_expect";
|
|
3
|
+
import render from "./layout.js";
|
|
4
|
+
// import { makeSegments, applyTextStyle, textStyleToArray } from "./internal.js";
|
|
42
5
|
// import renderMJML = require("./mjml-layout");
|
|
43
|
-
|
|
6
|
+
import { renderMJML } from "./mjml-layout.js";
|
|
44
7
|
// import tags = require("./tags");
|
|
45
|
-
|
|
8
|
+
import * as tags from "./tags.js";
|
|
46
9
|
const { p } = tags;
|
|
47
|
-
|
|
48
|
-
|
|
10
|
+
describe("layout", () => {
|
|
11
|
+
it("renders a simple layout", () => {
|
|
49
12
|
const blockDispatch = {
|
|
50
13
|
wrapTop(segment, ix, s) {
|
|
51
14
|
return p(s);
|
|
@@ -55,9 +18,9 @@ const { p } = tags;
|
|
|
55
18
|
},
|
|
56
19
|
};
|
|
57
20
|
const markup = { above: [{ type: "reverseIt", theString: "foobar" }] };
|
|
58
|
-
|
|
21
|
+
expect(render({ blockDispatch, layout: markup })).toBe("<p>raboof</p>");
|
|
59
22
|
});
|
|
60
|
-
|
|
23
|
+
it("renders a nested layout", () => {
|
|
61
24
|
const blockDispatch = {};
|
|
62
25
|
const markup = {
|
|
63
26
|
above: [
|
|
@@ -75,27 +38,27 @@ const { p } = tags;
|
|
|
75
38
|
},
|
|
76
39
|
],
|
|
77
40
|
};
|
|
78
|
-
|
|
41
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<div class="row"><div class="col-6">hello</div><div class="col-6">world</div></div><div class="row"><div class="col-6">bar</div><div class="col-6">foo</div></div>');
|
|
79
42
|
});
|
|
80
|
-
|
|
43
|
+
it("renders a container custom element", () => {
|
|
81
44
|
const blockDispatch = {};
|
|
82
45
|
const markup = {
|
|
83
46
|
type: "container",
|
|
84
47
|
htmlElement: "section",
|
|
85
48
|
contents: { type: "blank", contents: "bar" },
|
|
86
49
|
};
|
|
87
|
-
|
|
50
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<section style=" ">bar</section>');
|
|
88
51
|
});
|
|
89
|
-
|
|
52
|
+
it("renders a container custom class", () => {
|
|
90
53
|
const blockDispatch = {};
|
|
91
54
|
const markup = {
|
|
92
55
|
type: "container",
|
|
93
56
|
contents: { type: "blank", contents: "bar" },
|
|
94
57
|
customClass: "py-5",
|
|
95
58
|
};
|
|
96
|
-
|
|
59
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<div class="py-5" style=" ">bar</div>');
|
|
97
60
|
});
|
|
98
|
-
|
|
61
|
+
it("renders a container custom element with class", () => {
|
|
99
62
|
const blockDispatch = {};
|
|
100
63
|
const markup = {
|
|
101
64
|
type: "container",
|
|
@@ -103,9 +66,9 @@ const { p } = tags;
|
|
|
103
66
|
contents: { type: "blank", contents: "bar" },
|
|
104
67
|
customClass: "py-5",
|
|
105
68
|
};
|
|
106
|
-
|
|
69
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<section class="py-5" style=" ">bar</section>');
|
|
107
70
|
});
|
|
108
|
-
|
|
71
|
+
it("renders a nested container custom element", () => {
|
|
109
72
|
const blockDispatch = {};
|
|
110
73
|
const markup = {
|
|
111
74
|
type: "container",
|
|
@@ -117,9 +80,9 @@ const { p } = tags;
|
|
|
117
80
|
},
|
|
118
81
|
customClass: "py-5",
|
|
119
82
|
};
|
|
120
|
-
|
|
83
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<section class="py-5" style=" "><section style=" ">bar</section></section>');
|
|
121
84
|
});
|
|
122
|
-
|
|
85
|
+
it("renders a container with padding", () => {
|
|
123
86
|
const blockDispatch = {};
|
|
124
87
|
const markup = {
|
|
125
88
|
type: "container",
|
|
@@ -128,28 +91,28 @@ const { p } = tags;
|
|
|
128
91
|
},
|
|
129
92
|
contents: { type: "blank", contents: "bar" },
|
|
130
93
|
};
|
|
131
|
-
|
|
94
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<div style="padding:2rem; ">bar</div>');
|
|
132
95
|
});
|
|
133
|
-
|
|
96
|
+
it("renders styled text in container with single textStyle", () => {
|
|
134
97
|
const blockDispatch = {};
|
|
135
98
|
const markup = {
|
|
136
99
|
type: "container",
|
|
137
100
|
contents: { type: "blank", contents: "bar", textStyle: "h1" },
|
|
138
101
|
};
|
|
139
|
-
|
|
102
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<div style=" "><h1>bar</h1></div>');
|
|
140
103
|
const markup1 = {
|
|
141
104
|
type: "container",
|
|
142
105
|
contents: { type: "blank", contents: "bar", textStyle: "fw-bold" },
|
|
143
106
|
};
|
|
144
|
-
|
|
107
|
+
expect(render({ blockDispatch, layout: markup1 })).toBe('<div style=" "><span class="fw-bold">bar</span></div>');
|
|
145
108
|
});
|
|
146
|
-
|
|
109
|
+
it("renders styled text in container with array textStyle", () => {
|
|
147
110
|
const blockDispatch = {};
|
|
148
111
|
const markup = {
|
|
149
112
|
type: "container",
|
|
150
113
|
contents: { type: "blank", contents: "bar", textStyle: ["h1"] },
|
|
151
114
|
};
|
|
152
|
-
|
|
115
|
+
expect(render({ blockDispatch, layout: markup })).toBe('<div style=" "><h1>bar</h1></div>');
|
|
153
116
|
const markup1 = {
|
|
154
117
|
type: "container",
|
|
155
118
|
contents: {
|
|
@@ -158,7 +121,7 @@ const { p } = tags;
|
|
|
158
121
|
textStyle: ["fw-bold", "small"],
|
|
159
122
|
},
|
|
160
123
|
};
|
|
161
|
-
|
|
124
|
+
expect(render({ blockDispatch, layout: markup1 })).toBe('<div style=" "><span class="fw-bold small">bar</span></div>');
|
|
162
125
|
const markup2 = {
|
|
163
126
|
type: "container",
|
|
164
127
|
contents: {
|
|
@@ -167,26 +130,26 @@ const { p } = tags;
|
|
|
167
130
|
textStyle: ["h1", "fw-bold", "small"],
|
|
168
131
|
},
|
|
169
132
|
};
|
|
170
|
-
|
|
133
|
+
expect(render({ blockDispatch, layout: markup2 })).toBe('<div style=" "><h1 class="fw-bold small">bar</h1></div>');
|
|
171
134
|
});
|
|
172
|
-
|
|
135
|
+
it("renders top-level text styled with array textStyle", () => {
|
|
173
136
|
const blockDispatch = {};
|
|
174
137
|
const markup = {
|
|
175
138
|
type: "blank",
|
|
176
139
|
contents: "bar",
|
|
177
140
|
textStyle: ["h1"],
|
|
178
141
|
};
|
|
179
|
-
|
|
142
|
+
expect(render({ blockDispatch, layout: markup })).toBe("<h1>bar</h1>");
|
|
180
143
|
const markup1 = {
|
|
181
144
|
type: "blank",
|
|
182
145
|
contents: "bar",
|
|
183
146
|
textStyle: ["fw-bold", "small"],
|
|
184
147
|
};
|
|
185
|
-
|
|
148
|
+
expect(render({ blockDispatch, layout: markup1 })).toBe('<span class="fw-bold small">bar</span>');
|
|
186
149
|
});
|
|
187
|
-
|
|
150
|
+
it("renders text with class", () => {
|
|
188
151
|
const blockDispatch = {};
|
|
189
|
-
|
|
152
|
+
expect(render({
|
|
190
153
|
blockDispatch,
|
|
191
154
|
layout: {
|
|
192
155
|
type: "blank",
|
|
@@ -194,7 +157,7 @@ const { p } = tags;
|
|
|
194
157
|
customClass: ["myclass"],
|
|
195
158
|
},
|
|
196
159
|
})).toBe('<span class="myclass">bar</span>');
|
|
197
|
-
|
|
160
|
+
expect(render({
|
|
198
161
|
blockDispatch,
|
|
199
162
|
layout: {
|
|
200
163
|
type: "blank",
|
|
@@ -203,7 +166,7 @@ const { p } = tags;
|
|
|
203
166
|
customClass: ["myclass"],
|
|
204
167
|
},
|
|
205
168
|
})).toBe('<h1 class="myclass">bar</h1>');
|
|
206
|
-
|
|
169
|
+
expect(render({
|
|
207
170
|
blockDispatch,
|
|
208
171
|
layout: {
|
|
209
172
|
type: "blank",
|
|
@@ -212,7 +175,7 @@ const { p } = tags;
|
|
|
212
175
|
customClass: ["myclass"],
|
|
213
176
|
},
|
|
214
177
|
})).toBe('<span class="muted myclass">bar</span>');
|
|
215
|
-
|
|
178
|
+
expect(render({
|
|
216
179
|
blockDispatch,
|
|
217
180
|
layout: {
|
|
218
181
|
type: "container",
|
|
@@ -224,7 +187,7 @@ const { p } = tags;
|
|
|
224
187
|
},
|
|
225
188
|
})).toBe('<div style=" "><span class="myclass">bar</span></div>');
|
|
226
189
|
});
|
|
227
|
-
|
|
190
|
+
it("renders a dropdown menu", () => {
|
|
228
191
|
const blockDispatch = {};
|
|
229
192
|
const markup = {
|
|
230
193
|
type: "dropdown_menu",
|
|
@@ -235,10 +198,10 @@ const { p } = tags;
|
|
|
235
198
|
{ type: "blank", contents: "Option 2" },
|
|
236
199
|
],
|
|
237
200
|
};
|
|
238
|
-
const result = (
|
|
239
|
-
|
|
201
|
+
const result = render({ blockDispatch, layout: markup });
|
|
202
|
+
expect(result).toMatch(/^<div class="dropdown d-inline"><button class="btn btn-primary d-inline-block dropdown-toggle" data-boundary="viewport" type="button" id="actiondd[a-f0-9]+" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Actions<\/button><div class="dropdown-menu" aria-labelledby="actiondd[a-f0-9]+"><div class="d-flex flex-column px-2">Option 1Option 2<\/div><\/div><\/div>$/);
|
|
240
203
|
});
|
|
241
|
-
|
|
204
|
+
it("renders a card with a footer", () => {
|
|
242
205
|
const blockDispatch = {};
|
|
243
206
|
const markup = {
|
|
244
207
|
type: "card",
|
|
@@ -246,15 +209,15 @@ const { p } = tags;
|
|
|
246
209
|
contents: { type: "blank", contents: "Card Body" },
|
|
247
210
|
footer: { type: "blank", contents: "Card footer" },
|
|
248
211
|
};
|
|
249
|
-
const result = (
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
212
|
+
const result = render({ blockDispatch, layout: markup });
|
|
213
|
+
expect(result).toContain('<div class="card mt-4 shadow">');
|
|
214
|
+
expect(result).toContain('<span class="card-header">');
|
|
215
|
+
expect(result).toContain('<h5 class="m-0 fw-bold text-primary d-inline">Card Title</h5>');
|
|
216
|
+
expect(result).toContain('<div class="card-body">Card Body</div>');
|
|
217
|
+
expect(result).toContain('<div class="card-footer">Card footer</div>');
|
|
218
|
+
expect(result).toMatch(/<\/div>\s*<\/div>$/);
|
|
256
219
|
});
|
|
257
|
-
|
|
220
|
+
it("renders a container with background image", () => {
|
|
258
221
|
const blockDispatch = {};
|
|
259
222
|
const markup = {
|
|
260
223
|
type: "container",
|
|
@@ -262,13 +225,13 @@ const { p } = tags;
|
|
|
262
225
|
bgFileId: "123",
|
|
263
226
|
contents: { type: "blank", contents: "Content with background" },
|
|
264
227
|
};
|
|
265
|
-
const result = (
|
|
266
|
-
|
|
267
|
-
|
|
228
|
+
const result = render({ blockDispatch, layout: markup });
|
|
229
|
+
expect(result).toContain('<img class="containerbgimage " style="object-fit:contain" alt="" src="/files/serve/123">');
|
|
230
|
+
expect(result).toContain("Content with background");
|
|
268
231
|
});
|
|
269
232
|
});
|
|
270
|
-
|
|
271
|
-
|
|
233
|
+
describe("render", () => {
|
|
234
|
+
it("renders a layout with multiple nested containers", () => {
|
|
272
235
|
const blockDispatch = {};
|
|
273
236
|
const markup = {
|
|
274
237
|
type: "container",
|
|
@@ -280,30 +243,30 @@ const { p } = tags;
|
|
|
280
243
|
},
|
|
281
244
|
},
|
|
282
245
|
};
|
|
283
|
-
const result = (
|
|
284
|
-
|
|
246
|
+
const result = render({ blockDispatch, layout: markup });
|
|
247
|
+
expect(result).toBe('<div style=" "><div style=" "><div style=" ">Nested Content</div></div></div>');
|
|
285
248
|
});
|
|
286
|
-
|
|
249
|
+
it("renders a layout with a custom class", () => {
|
|
287
250
|
const blockDispatch = {};
|
|
288
251
|
const markup = {
|
|
289
252
|
type: "container",
|
|
290
253
|
customClass: ["custom-class"],
|
|
291
254
|
contents: { type: "blank", contents: "Content with class" },
|
|
292
255
|
};
|
|
293
|
-
const result = (
|
|
294
|
-
|
|
256
|
+
const result = render({ blockDispatch, layout: markup });
|
|
257
|
+
expect(result).toBe('<div class="custom-class" style=" ">Content with class</div>');
|
|
295
258
|
});
|
|
296
|
-
|
|
259
|
+
it("renders a layout with inline styles", () => {
|
|
297
260
|
const blockDispatch = {};
|
|
298
261
|
const markup = {
|
|
299
262
|
type: "container",
|
|
300
263
|
style: { backgroundColor: "blue", color: "white" },
|
|
301
264
|
contents: { type: "blank", contents: "Styled Content" },
|
|
302
265
|
};
|
|
303
|
-
const result = (
|
|
304
|
-
|
|
266
|
+
const result = render({ blockDispatch, layout: markup });
|
|
267
|
+
expect(result).toBe('<div style="backgroundColor:blue;color:white; ">Styled Content</div>');
|
|
305
268
|
});
|
|
306
|
-
|
|
269
|
+
it("renders a layout with a combination of textStyle and customClass", () => {
|
|
307
270
|
const blockDispatch = {};
|
|
308
271
|
const markup = {
|
|
309
272
|
type: "blank",
|
|
@@ -311,19 +274,19 @@ const { p } = tags;
|
|
|
311
274
|
textStyle: ["h1", "fw-bold"],
|
|
312
275
|
customClass: ["custom-class"],
|
|
313
276
|
};
|
|
314
|
-
const result = (
|
|
315
|
-
|
|
277
|
+
const result = render({ blockDispatch, layout: markup });
|
|
278
|
+
expect(result).toBe('<h1 class="fw-bold custom-class">Styled and Classed Content</h1>');
|
|
316
279
|
});
|
|
317
|
-
|
|
280
|
+
it("renders a layout with an empty container", () => {
|
|
318
281
|
const blockDispatch = {};
|
|
319
282
|
const markup = {
|
|
320
283
|
type: "container",
|
|
321
284
|
contents: null,
|
|
322
285
|
};
|
|
323
|
-
const result = (
|
|
324
|
-
|
|
286
|
+
const result = render({ blockDispatch, layout: markup });
|
|
287
|
+
expect(result).toBe('<div style=" "></div>');
|
|
325
288
|
});
|
|
326
|
-
|
|
289
|
+
it("renders a layout with a dropdown menu containing multiple actions", () => {
|
|
327
290
|
const blockDispatch = {};
|
|
328
291
|
const markup = {
|
|
329
292
|
type: "dropdown_menu",
|
|
@@ -335,14 +298,14 @@ const { p } = tags;
|
|
|
335
298
|
{ type: "blank", contents: "Action 3" },
|
|
336
299
|
],
|
|
337
300
|
};
|
|
338
|
-
const result = (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
301
|
+
const result = render({ blockDispatch, layout: markup });
|
|
302
|
+
expect(result).toContain('<div class="dropdown d-inline">');
|
|
303
|
+
expect(result).toContain('class="btn btn-secondary d-inline-block dropdown-toggle"');
|
|
304
|
+
expect(result).toContain(">Menu</button>");
|
|
305
|
+
expect(result).toContain('<div class="dropdown-menu"');
|
|
306
|
+
expect(result).toContain("Action 1Action 2Action 3</div>");
|
|
344
307
|
});
|
|
345
|
-
|
|
308
|
+
it("renders a card layout with title, body, and footer", () => {
|
|
346
309
|
const blockDispatch = {};
|
|
347
310
|
const markup = {
|
|
348
311
|
type: "card",
|
|
@@ -350,14 +313,14 @@ const { p } = tags;
|
|
|
350
313
|
contents: { type: "blank", contents: "Card Body" },
|
|
351
314
|
footer: { type: "blank", contents: "Card Footer" },
|
|
352
315
|
};
|
|
353
|
-
const result = (
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
316
|
+
const result = render({ blockDispatch, layout: markup });
|
|
317
|
+
expect(result).toContain('<div class="card mt-4 shadow">');
|
|
318
|
+
expect(result).toContain('<span class="card-header">');
|
|
319
|
+
expect(result).toContain('<h5 class="m-0 fw-bold text-primary d-inline">Card Title</h5>');
|
|
320
|
+
expect(result).toContain('<div class="card-body">Card Body</div>');
|
|
321
|
+
expect(result).toContain('<div class="card-footer">Card Footer</div>');
|
|
359
322
|
});
|
|
360
|
-
|
|
323
|
+
it("renders a card layout with class", () => {
|
|
361
324
|
const blockDispatch = {};
|
|
362
325
|
const markup = {
|
|
363
326
|
type: "card",
|
|
@@ -365,10 +328,10 @@ const { p } = tags;
|
|
|
365
328
|
contents: { type: "blank", contents: "Card Body" },
|
|
366
329
|
class: "foo",
|
|
367
330
|
};
|
|
368
|
-
const result = (
|
|
369
|
-
|
|
331
|
+
const result = render({ blockDispatch, layout: markup });
|
|
332
|
+
expect(result).toBe('<div class="card mt-4 shadow foo"><span class="card-header"><h5 class="m-0 fw-bold text-primary d-inline">Card Title</h5></span><div class="card-body">Card Body</div></div>');
|
|
370
333
|
});
|
|
371
|
-
|
|
334
|
+
it("renders a layout with a container and background image", () => {
|
|
372
335
|
const blockDispatch = {};
|
|
373
336
|
const markup = {
|
|
374
337
|
type: "container",
|
|
@@ -376,11 +339,11 @@ const { p } = tags;
|
|
|
376
339
|
bgFileId: "456",
|
|
377
340
|
contents: { type: "blank", contents: "Background Content" },
|
|
378
341
|
};
|
|
379
|
-
const result = (
|
|
380
|
-
|
|
381
|
-
|
|
342
|
+
const result = render({ blockDispatch, layout: markup });
|
|
343
|
+
expect(result).toContain('<img class="containerbgimage " style="object-fit:contain" alt="" src="/files/serve/456">');
|
|
344
|
+
expect(result).toContain("Background Content");
|
|
382
345
|
});
|
|
383
|
-
|
|
346
|
+
it("renders a layout with breadcrumbs", () => {
|
|
384
347
|
const blockDispatch = {};
|
|
385
348
|
const markup = {
|
|
386
349
|
type: "breadcrumbs",
|
|
@@ -391,10 +354,10 @@ const { p } = tags;
|
|
|
391
354
|
right: "Right Content",
|
|
392
355
|
after: "After Content",
|
|
393
356
|
};
|
|
394
|
-
const result = (
|
|
395
|
-
|
|
357
|
+
const result = render({ blockDispatch, layout: markup });
|
|
358
|
+
expect(result).toBe(`<nav aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="/">Home</a></li><li class="breadcrumb-item fw-bold" aria-current="page"><a href="/page">Page</a></li><li class="ms-3">After Content</li><li class="ms-auto">Right Content</li></ol></nav>`);
|
|
396
359
|
});
|
|
397
|
-
|
|
360
|
+
it("renders a layout with a table", () => {
|
|
398
361
|
const blockDispatch = {};
|
|
399
362
|
const markup = {
|
|
400
363
|
type: "table",
|
|
@@ -411,10 +374,10 @@ const { p } = tags;
|
|
|
411
374
|
],
|
|
412
375
|
],
|
|
413
376
|
};
|
|
414
|
-
const result = (
|
|
415
|
-
|
|
377
|
+
const result = render({ blockDispatch, layout: markup });
|
|
378
|
+
expect(result).toBe("<table><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>");
|
|
416
379
|
});
|
|
417
|
-
|
|
380
|
+
it("renders a layout with an image", () => {
|
|
418
381
|
const blockDispatch = {};
|
|
419
382
|
const markup = {
|
|
420
383
|
type: "image",
|
|
@@ -423,10 +386,10 @@ const { p } = tags;
|
|
|
423
386
|
alt: "Test image",
|
|
424
387
|
style: { width: "100px", height: "100px" },
|
|
425
388
|
};
|
|
426
|
-
const result = (
|
|
427
|
-
|
|
389
|
+
const result = render({ blockDispatch, layout: markup });
|
|
390
|
+
expect(result).toBe(`<img alt="Test image" style="width:100px;height:100px" src="/files/serve/123">`);
|
|
428
391
|
});
|
|
429
|
-
|
|
392
|
+
it("renders a layout with a link", () => {
|
|
430
393
|
const blockDispatch = {};
|
|
431
394
|
const markup = {
|
|
432
395
|
type: "link",
|
|
@@ -436,19 +399,19 @@ const { p } = tags;
|
|
|
436
399
|
link_size: "btn-lg",
|
|
437
400
|
link_icon: "fa fa-link",
|
|
438
401
|
};
|
|
439
|
-
const result = (
|
|
440
|
-
|
|
402
|
+
const result = render({ blockDispatch, layout: markup });
|
|
403
|
+
expect(result).toBe('<a href="/test" class="btn btn-primary btn-lg d-inline-block"><i class="fa fa-link"></i> Click Me</a>');
|
|
441
404
|
});
|
|
442
|
-
|
|
405
|
+
it("renders a layout with a line break", () => {
|
|
443
406
|
const blockDispatch = {};
|
|
444
407
|
const markup = {
|
|
445
408
|
type: "line_break",
|
|
446
409
|
hr: true,
|
|
447
410
|
};
|
|
448
|
-
const result = (
|
|
449
|
-
|
|
411
|
+
const result = render({ blockDispatch, layout: markup });
|
|
412
|
+
expect(result).toBe("<hr>");
|
|
450
413
|
});
|
|
451
|
-
|
|
414
|
+
it("render a layout with search bar", () => {
|
|
452
415
|
const blockDispatch = {};
|
|
453
416
|
const markup = {
|
|
454
417
|
type: "search_bar",
|
|
@@ -456,10 +419,10 @@ const { p } = tags;
|
|
|
456
419
|
autofocus: true,
|
|
457
420
|
contents: { type: "blank", contents: "Search Content" },
|
|
458
421
|
};
|
|
459
|
-
const result = (
|
|
460
|
-
|
|
422
|
+
const result = render({ blockDispatch, layout: markup });
|
|
423
|
+
expect(result).toMatch(/^<form action="\/search" method="get"><div class="input-group search-bar" id="search-input-group-[a-f0-9]+"><button class="btn btn-outline-secondary search-bar" type="submit" id="button-search-submit"><i class="fas fa-search"><\/i><\/button><input type="search" class="form-control search-bar br-none" autofocus placeholder="Search for..." id="inputq_[a-f0-9]+" name="q" aria-label="Search" aria-describedby="button-search-submit"><button class="btn btn-outline-secondary dropdown-toggle search-bar" id="dd[a-f0-9]+" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="align_dropdown\('[a-f0-9]+'\)"><\/button><div class="dropdown-menu search-bar p-2" id="dm[a-f0-9]+" aria-labelledby="dd[a-f0-9]+">Search Content<\/div><\/div><\/form>$/);
|
|
461
424
|
});
|
|
462
|
-
|
|
425
|
+
it("renders a layout with a container and gradient background", () => {
|
|
463
426
|
const blockDispatch = {};
|
|
464
427
|
const markup = {
|
|
465
428
|
type: "container",
|
|
@@ -469,30 +432,30 @@ const { p } = tags;
|
|
|
469
432
|
gradDirection: 45,
|
|
470
433
|
contents: { type: "blank", contents: "Gradient Content" },
|
|
471
434
|
};
|
|
472
|
-
const result = (
|
|
473
|
-
|
|
435
|
+
const result = render({ blockDispatch, layout: markup });
|
|
436
|
+
expect(result).toBe(`<div style=" background-image: linear-gradient(45deg, #ff0000, #0000ff); ">Gradient Content</div>`);
|
|
474
437
|
});
|
|
475
|
-
|
|
438
|
+
it("renders a layout with a container and hover color", () => {
|
|
476
439
|
const blockDispatch = {};
|
|
477
440
|
const markup = {
|
|
478
441
|
type: "container",
|
|
479
442
|
hoverColor: "hover-primary",
|
|
480
443
|
contents: { type: "blank", contents: "Hover Content" },
|
|
481
444
|
};
|
|
482
|
-
const result = (
|
|
483
|
-
|
|
484
|
-
|
|
445
|
+
const result = render({ blockDispatch, layout: markup });
|
|
446
|
+
expect(result).toContain('class="hover-hover-primary"');
|
|
447
|
+
expect(result).toContain("Hover Content");
|
|
485
448
|
});
|
|
486
|
-
|
|
449
|
+
it("renders a layout with a container and transform styles", () => {
|
|
487
450
|
const blockDispatch = {};
|
|
488
451
|
const markup = {
|
|
489
452
|
type: "container",
|
|
490
453
|
transform: { rotate: "45deg", scaleX: "1.5" },
|
|
491
454
|
contents: { type: "blank", contents: "Transformed Content" },
|
|
492
455
|
};
|
|
493
|
-
const result = (
|
|
494
|
-
|
|
495
|
-
|
|
456
|
+
const result = render({ blockDispatch, layout: markup });
|
|
457
|
+
expect(result).toContain("transform: rotate(45deg) scaleX(1.5)");
|
|
458
|
+
expect(result).toContain("Transformed Content");
|
|
496
459
|
});
|
|
497
460
|
});
|
|
498
461
|
// describe("makeSegments", () => {
|
|
@@ -547,24 +510,24 @@ const { p } = tags;
|
|
|
547
510
|
// );
|
|
548
511
|
// });
|
|
549
512
|
// });
|
|
550
|
-
|
|
513
|
+
describe("MJML layout", () => {
|
|
551
514
|
const blockDispatch = {};
|
|
552
|
-
|
|
553
|
-
const result =
|
|
554
|
-
|
|
555
|
-
|
|
515
|
+
it("renders empty layout", () => {
|
|
516
|
+
const result = renderMJML({ blockDispatch, layout: {}, req: {} });
|
|
517
|
+
expect(result.markup).toBe(`<mj-section><mj-raw><div style="text-align: left !important; font-size: 16px;"></div></mj-raw></mj-section>`);
|
|
518
|
+
expect(result.backgroundColor).toBe(undefined);
|
|
556
519
|
});
|
|
557
|
-
|
|
520
|
+
it("renders text layout", () => {
|
|
558
521
|
const layout = { type: "blank", contents: "Hello world" };
|
|
559
|
-
const result =
|
|
560
|
-
|
|
561
|
-
|
|
522
|
+
const result = renderMJML({ blockDispatch, layout, req: {} });
|
|
523
|
+
expect(result.markup).toBe(`<mj-section><mj-raw><div style="text-align: left !important; font-size: 16px;">Hello world</div></mj-raw></mj-section>`);
|
|
524
|
+
expect(result.backgroundColor).toBe(undefined);
|
|
562
525
|
});
|
|
563
|
-
|
|
526
|
+
it("renders text header", () => {
|
|
564
527
|
const layout = { type: "blank", contents: "Hello world", textStyle: "h1" };
|
|
565
|
-
const result =
|
|
566
|
-
|
|
567
|
-
|
|
528
|
+
const result = renderMJML({ blockDispatch, layout, req: {} });
|
|
529
|
+
expect(result.markup).toBe(`<mj-section><mj-raw><div style="text-align: left !important; font-size: 16px;"><div style="font-size:2em;margin-top:0.67em;margin-bottom:0.67em;margin-left:0;margin-right:0;font-weight:bold">Hello world</div></div></mj-raw></mj-section>`);
|
|
530
|
+
expect(result.backgroundColor).toBe(undefined);
|
|
568
531
|
});
|
|
569
532
|
});
|
|
570
533
|
// describe("textStyleToArray", () => {
|