title-spec.js 1.98 KB
Newer Older
Zhou Yang's avatar
Zhou Yang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
(function() {
  describe('Simditor title button', function() {
    var $p, editor;
    editor = null;
    $p = null;
    beforeEach(function() {
      editor = spec.generateSimditor({
        content: '<p>paragraph 1</>',
        toolbar: ['title']
      });
      editor.focus();
      $p = editor.body.find('> p');
      editor.selection.setRangeAtStartOf($p);
      editor.inputManager.focused = true;
      return editor.trigger('selectionchanged');
    });
    afterEach(function() {
      spec.destroySimditor();
      return editor = null;
    });
    it("can convert paragraph to h1", function() {
      var $firstBlock, button;
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(true);
      expect($firstBlock.is('h1')).toBe(false);
      button = editor.toolbar.list.find('.toolbar-item-title').data('button');
      button.menuEl.find('.menu-item-h1').click();
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(false);
      expect($firstBlock.is('h1')).toBe(true);
      button.menuEl.find('.menu-item-normal').click();
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(true);
      return expect($firstBlock.is('h1')).toBe(false);
    });
    return it("can convert paragraph to h5", function() {
      var $firstBlock, button;
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(true);
      expect($firstBlock.is('h5')).toBe(false);
      button = editor.toolbar.list.find('.toolbar-item-title').data('button');
      button.menuEl.find('.menu-item-h5').click();
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(false);
      expect($firstBlock.is('h5')).toBe(true);
      button.menuEl.find('.menu-item-normal').click();
      $firstBlock = editor.body.children().first();
      expect($firstBlock.is('p')).toBe(true);
      return expect($firstBlock.is('h5')).toBe(false);
    });
  });

}).call(this);