From 46f582a966daa1af3405e1b5701de5863bf86df8 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 2 Sep 2021 14:58:35 +0200 Subject: [PATCH] New test in headless --- test/specs/grapesjs/headless.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/specs/grapesjs/headless.js b/test/specs/grapesjs/headless.js index 918136dec..a9c3a0ac8 100644 --- a/test/specs/grapesjs/headless.js +++ b/test/specs/grapesjs/headless.js @@ -41,6 +41,35 @@ describe('GrapesJS Headless', () => { expect(editor.getCss()).toBe(''); // same as default }); + test('Add components with children', () => { + const res = editor.addComponents([ + { + tagName: 'h1', + type: 'text', + components: [ + { + type: 'textnode', + removable: false, + draggable: false, + highlightable: 0, + copyable: false, + selectable: true, + content: 'Hello!', + _innertext: false + } + ] + } + ]); + expect(res.length).toBe(1); + const resHtml = '

Hello!

'; + const comp = res[0]; + expect(comp.toHTML()).toBe(resHtml); + expect(editor.Selectors.getAll().length).toBe(0); + expect(editor.Css.getAll().length).toBe(0); + expect(editor.getHtml()).toBe(resHtml); + expect(editor.getCss()).toBe(''); + }); + test('Add styles', () => { const res = editor.addStyle(styleObj); expect(res.length).toBe(1);