Browse Source

Add headless test for components

pull/3671/head
Artur Arseniev 5 years ago
parent
commit
ae8435c381
  1. 30
      test/specs/grapesjs/headless.js

30
test/specs/grapesjs/headless.js

@ -1,11 +1,39 @@
/**
* @jest-environment node
*/
let editor;
describe('GrapesJS Headless', () => {
test('Can init editor', () => {
test('Can init and destroy an editor', () => {
const editor = grapesjs.init({ headless: true });
expect(editor).toBeTruthy();
editor.destroy();
});
describe('Headless operations', () => {
beforeEach(() => {
editor = grapesjs.init({ headless: true });
});
afterEach(() => {
editor.destroy();
});
test('Add components', () => {
const res = editor.addComponents({
attributes: { class: 'cls', test: 'value' },
components: { type: 'textnode', content: 'Test' }
});
expect(res.length).toBe(1);
const comp = res[0];
const resultHTML = '<div class="cls" test="value">Test</div>';
expect(comp.toHTML()).toBe(resultHTML);
expect(editor.Selectors.getAll().length).toBe(1); // 1 selector is created
expect(editor.Css.getAll().length).toBe(0); // No CSS
expect(editor.getHtml()).toBe(resultHTML);
expect(editor.getCss()).toBe(editor.getConfig().protectedCss); // same as default
});
test('Add styles', () => {});
});
});

Loading…
Cancel
Save