const assert = require("assert"); const { Engine } = require("mrml-wasm/nodejs/mrml_wasm"); const { describe, it } = require("node:test"); describe('mrml-wasm in node', function () { it('should render to html', function () { const engine = new Engine(); const result = engine.toHtml("Hello world"); assert.equal(result.type, 'success'); }); it('should disable the comments', function () { const engine = new Engine(); engine.setRenderOptions({ disableComments: true, fonts: {}, }); const result = engine.toHtml(` Hello world `); assert.equal(result.type, 'success'); assert.doesNotMatch(result.content, /Goodbye/); }); it('should use noop include loader by default', function () { const engine = new Engine(); engine.setRenderOptions({ disableComments: true, fonts: {}, }); const result = engine.toHtml(` `); assert.equal(result.type, 'error'); }); it('should use memory include loader', function () { const engine = new Engine(); engine.setParserOptions({ includeLoader: { type: 'memory', content: { './header.mjml': 'Hello World', }, }, }); engine.setRenderOptions({ disableComments: true, fonts: {}, }); const result = engine.toHtml(` `); assert.equal(result.type, 'success'); assert.match(result.content, /Hello/); }); it('should use network include loader', async function () { const engine = new Engine(); engine.setAsyncParserOptions({ includeLoader: { type: 'reqwest', headers: {}, }, }); engine.setRenderOptions({ disableComments: true, fonts: {}, }); const result = await engine.toHtmlAsync(` `); assert.equal(result.type, 'success'); assert.match(result.content, /Hello World/); }); });