1 | import {
|
2 | liquidToBuilder,
|
3 | liquidToAst,
|
4 | parsedLiquidToHtml,
|
5 | htmlToAst,
|
6 | htmlAstToBuilder,
|
7 | } from '../src/functions/liquid-to-builder';
|
8 | import * as productPage from './liquid/product.liquid';
|
9 | import { debugLog, debugFile } from './modules/helpers';
|
10 | import * as stringify from 'json-stringify-safe';
|
11 |
|
12 | test('Product page', async () => {
|
13 | const parsedTemplateItems = liquidToAst(productPage);
|
14 | const html = await parsedLiquidToHtml(parsedTemplateItems);
|
15 | const htmlNodes = htmlToAst(html);
|
16 | const blocks = htmlAstToBuilder(htmlNodes);
|
17 |
|
18 | const everything = { parsedTemplateItems, html, htmlNodes, blocks };
|
19 | debugLog('everything', everything);
|
20 | const ignoreKeys = new Set(['liquid', 'input']);
|
21 | await debugFile(
|
22 | 'everything.json',
|
23 | stringify(everything, (key, value) => (ignoreKeys.has(key) ? undefined : value), 2)
|
24 | );
|
25 | await debugFile(
|
26 | 'html.html',
|
27 | html
|
28 | );
|
29 | expect(blocks).toBeTruthy();
|
30 | });
|
31 |
|
32 | test('Product page full', async () => {
|
33 | const blocks = liquidToBuilder(productPage);
|
34 | expect(blocks).toBeTruthy();
|
35 | });
|