From 5344ca23c512dc321c6c95894fb5f58ebc7c7ab7 Mon Sep 17 00:00:00 2001 From: Cory Forsyth Date: Tue, 11 Aug 2015 14:55:10 -0400 Subject: [PATCH] Ensure that the editor triggers an update when clicking "heading" fixes #58 --- src/js/commands/format-block.js | 2 ++ src/js/commands/image.js | 2 +- tests/acceptance/editor-commands-test.js | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/js/commands/format-block.js b/src/js/commands/format-block.js index cfc2cfb3a..f0139883c 100644 --- a/src/js/commands/format-block.js +++ b/src/js/commands/format-block.js @@ -29,6 +29,7 @@ class FormatBlockCommand extends TextFormatCommand { editor.rerender(); editor.selectSections(activeSections); + this.editor.didUpdate(); } unexec() { @@ -41,6 +42,7 @@ class FormatBlockCommand extends TextFormatCommand { editor.rerender(); editor.selectSections(activeSections); + this.editor.didUpdate(); } } diff --git a/src/js/commands/image.js b/src/js/commands/image.js index 659e7594c..3557f9d77 100644 --- a/src/js/commands/image.js +++ b/src/js/commands/image.js @@ -17,6 +17,6 @@ export default class ImageCommand extends Command { sections.forEach(section => section.renderNode.scheduleForRemoval()); this.editor.rerender(); - this.editor.trigger('update'); + this.editor.didUpdate(); } } diff --git a/tests/acceptance/editor-commands-test.js b/tests/acceptance/editor-commands-test.js index 5cd12f03a..233f02142 100644 --- a/tests/acceptance/editor-commands-test.js +++ b/tests/acceptance/editor-commands-test.js @@ -71,6 +71,24 @@ test('highlight text, click "heading" button turns text into h2 header', (assert }); }); +test('click heading button triggers update', (assert) => { + const done = assert.async(); + const triggered = []; + const triggerFn = editor.trigger; + editor.trigger = (name, ...args) => { + triggered.push(name); + triggerFn.call(editor, name, ...args); + }; + + setTimeout(() => { + Helpers.toolbar.clickButton(assert, 'heading'); + assert.ok(triggered.indexOf('update') !== -1, + 'update was triggered'); + + done(); + }); +}); + test('highlighting heading text activates toolbar button', (assert) => { const done = assert.async();