mirror of https://github.com/artf/grapesjs.git
1 changed files with 29 additions and 1 deletions
@ -1,11 +1,39 @@ |
|||||
/** |
/** |
||||
* @jest-environment node |
* @jest-environment node |
||||
*/ |
*/ |
||||
|
let editor; |
||||
|
|
||||
describe('GrapesJS Headless', () => { |
describe('GrapesJS Headless', () => { |
||||
test('Can init editor', () => { |
test('Can init and destroy an editor', () => { |
||||
const editor = grapesjs.init({ headless: true }); |
const editor = grapesjs.init({ headless: true }); |
||||
expect(editor).toBeTruthy(); |
expect(editor).toBeTruthy(); |
||||
editor.destroy(); |
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…
Reference in new issue