header.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import Delta from 'quill-delta';
  2. import Editor from '../../../core/editor';
  3. describe('Header', function() {
  4. it('add', function() {
  5. const editor = this.initialize(Editor, '<p><em>0123</em></p>');
  6. editor.formatText(4, 1, { header: 1 });
  7. expect(editor.getDelta()).toEqual(
  8. new Delta().insert('0123', { italic: true }).insert('\n', { header: 1 }),
  9. );
  10. expect(editor.scroll.domNode).toEqualHTML('<h1><em>0123</em></h1>');
  11. });
  12. it('remove', function() {
  13. const editor = this.initialize(Editor, '<h1><em>0123</em></h1>');
  14. editor.formatText(4, 1, { header: false });
  15. expect(editor.getDelta()).toEqual(
  16. new Delta().insert('0123', { italic: true }).insert('\n'),
  17. );
  18. expect(editor.scroll.domNode).toEqualHTML('<p><em>0123</em></p>');
  19. });
  20. it('change', function() {
  21. const editor = this.initialize(Editor, '<h1><em>0123</em></h1>');
  22. editor.formatText(4, 1, { header: 2 });
  23. expect(editor.getDelta()).toEqual(
  24. new Delta().insert('0123', { italic: true }).insert('\n', { header: 2 }),
  25. );
  26. expect(editor.scroll.domNode).toEqualHTML('<h2><em>0123</em></h2>');
  27. });
  28. });