inline.js 1009 B

1234567891011121314151617181920212223242526272829
  1. import Scroll from '../../../blots/scroll';
  2. describe('Inline', function() {
  3. it('format order', function() {
  4. const scroll = this.initialize(Scroll, '<p>Hello World!</p>');
  5. scroll.formatAt(0, 1, 'bold', true);
  6. scroll.formatAt(0, 1, 'italic', true);
  7. scroll.formatAt(2, 1, 'italic', true);
  8. scroll.formatAt(2, 1, 'bold', true);
  9. expect(scroll.domNode).toEqualHTML(
  10. '<p><strong><em>H</em></strong>e<strong><em>l</em></strong>lo World!</p>',
  11. );
  12. });
  13. it('reorder', function() {
  14. const scroll = this.initialize(Scroll, '<p>0<strong>12</strong>3</p>');
  15. const p = scroll.domNode.firstChild;
  16. const em = document.createElement('em');
  17. Array.from(p.childNodes).forEach(function(node) {
  18. em.appendChild(node);
  19. });
  20. p.appendChild(em);
  21. expect(scroll.domNode).toEqualHTML('<p><em>0<strong>12</strong>3</em></p>');
  22. scroll.update();
  23. expect(scroll.domNode).toEqualHTML(
  24. '<p><em>0</em><strong><em>12</em></strong><em>3</em></p>',
  25. );
  26. });
  27. });