/* eslint-disable */
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: wysiwygarea,structuredheadings,toolbar,basicstyles,dialog,richcombo,undo */
/* eslint-enable */

// Clean up all instances been created on the page.
(function () {

  var comboName = "NumStyles";
  var itemName = "clear";

  bender.editor = {
    allowedForTests: "h1; h2; p"
  };

  bender.test({
    setUp: function () {
      //Anything to be run before each test if needed
    },
    "clear numbering style to a single autonumbered heading": function () {
      var bot = this.editorBot;
      var initialHtmlWithSelection = "<h1 class=\"autonumber autonumber-0 autonumber-N\">^foo</h1>";
      bot.setHtmlWithSelection(initialHtmlWithSelection);

      bot.combo(comboName, function (combo) {
        combo.onClick(itemName);
        assert.areSame(
            "<h1>^foo</h1>",
            bot.htmlWithSelection(),
            "cleared styling from h1"
        );

        bot.execCommand("undo");

        assert.areSame(
          initialHtmlWithSelection,
          bot.htmlWithSelection(),
          "undo the dropdown"
        );
      });
    },
    "clear numbering style to multiple autonumbered h1": function () {
      var bot = this.editorBot;
      var initialHtmlWithSelection =
        "[<h1 class=\"autonumber autonumber-0 autonumber-N\">foo</h1>" +
        "<p>bar</p>" +
        "<h1 class=\"autonumber autonumber-0 autonumber-N\">baz</h1>]";
      var initialHtmlWithoutSelection = initialHtmlWithSelection.substring(
        1,
        initialHtmlWithSelection.length - 1
      );
      bot.setHtmlWithSelection(initialHtmlWithSelection);

      bot.combo(comboName, function (combo) {
        combo.onClick(itemName);
        assert.areSame(
            "<h1>foo</h1><p>bar</p><h1>baz</h1>",
            bot.getData(),
            "cleared styling from headings"
        );

        bot.execCommand("undo");
        // this is weird, but the selection API returns the extra (internal) paragraphs
        // that are created to normalize the selection here
        assert.areSame(
          initialHtmlWithoutSelection,
          bot.getData(),
          "undo the dropdown"
        );
      });
    },
    "clear numbering style no-op on plain heading": function () {
      var bot = this.editorBot;
      bot.setHtmlWithSelection(
        "<h1>^foo</h1>"
      );

      bot.combo(comboName, function (combo) {
        combo.onClick(itemName);
        assert.areSame(
            "<h1>^foo</h1>",
            bot.htmlWithSelection(),
            "didn't do anything"
        );
      });
    }
  });
})();

@@ -2584,24 +2584,460 @@
 ;%0A      %7D);%0A
+    %7D,%0A    %22clear numbering style no-op on p%22: function () %7B%0A      var bot = this.editorBot;%0A      var initialHtmlWithSelection = %22%3Cp%3E%5Efoo%3C/p%3E%22;%0A      bot.setHtmlWithSelection(initialHtmlWithSelection);%0A%0A      bot.combo(comboName, function (combo) %7B%0A        combo.onClick(itemName);%0A        assert.areSame(%0A            initialHtmlWithSelection,%0A            bot.htmlWithSelection(),%0A            %22didn't do anything%22%0A        );%0A      %7D);%0A
     %7D%0A  %7D);%0A

make sure we don't mangle paragraphs if we accidentally clear it