Fix class toggle when choosing marked tokens with the query creator

Change-Id: I12441222ab318a74820625f3fff4d3cf64d161f8
diff --git a/dev/js/spec/queryCreatorSpec.js b/dev/js/spec/queryCreatorSpec.js
index 59547ef..21fffac 100644
--- a/dev/js/spec/queryCreatorSpec.js
+++ b/dev/js/spec/queryCreatorSpec.js
@@ -64,7 +64,7 @@
     "          <th>Der</th>" +
     "          <th>älteste</th>" +
     "          <th>lebende</th>" +
-    "          <th>Baum</th>" +
+    "          <th class=\"mark\">Baum</th>" +
     "        </tr>" +
     "      </thead>" +
     "      <tbody>" +
@@ -74,7 +74,7 @@
     "          <td>ART</td>" +
     "          <td>ADJA</td>" +
     "          <td>ADJA<br>ADJD</td>" +
-    "          <td class=\"matchkeyvalues\">" +
+    "          <td class=\"matchkeyvalues mark\">" +
     "            <div>case:nom</div>" +
     "            <div>gender:masc<br/>gender:fem</div>" +
     "            <div>number:sg</div>" +
@@ -91,7 +91,7 @@
     "          </td>" +
     "          <td>ADJA</td>" +
     "          <td></td>" +
-    "          <td>NN</td>" +
+    "          <td class=\"mark\">NN</td>" +
     "        </tr>" +
     "      </tbody>" +
     "    </table>";
@@ -581,5 +581,23 @@
       expect(cell.classList.contains("chosen")).toBeTruthy();
       expect(qc.toString()).toEqual("[opennlp/p='morphemes:.::_SORSZ \\\\ZERO::NOM \\\'period::PUNCT\\\'']");
     });
+
+    it('should respect marked elements', function () {
+      var matchTable = matchTableComplexFactory();
+      var qc = qcClass.create(matchTable);
+      expect(qc.toString()).toEqual("");
+
+      var cell = matchTable.querySelector("thead > tr > th:nth-child(6)");
+      expect(cell.classList.contains("mark")).toBeTruthy();
+      expect(cell.classList.contains("chosen")).toBeFalsy();
+
+      cell.click();
+      expect(cell.classList.contains("mark")).toBeTruthy();
+      expect(cell.classList.contains("chosen")).toBeTruthy();
+
+      cell.click();
+      expect(cell.classList.contains("mark")).toBeTruthy();
+      expect(cell.classList.contains("chosen")).toBeFalsy();
+    });
   });
 });