Update querycreator specification

Change-Id: Idee0411261ecab9ccb849792e8904f177141c7d7
diff --git a/dev/js/spec/queryCreatorSpec.js b/dev/js/spec/queryCreatorSpec.js
index 5967401..8b79fbe 100644
--- a/dev/js/spec/queryCreatorSpec.js
+++ b/dev/js/spec/queryCreatorSpec.js
@@ -1,8 +1,7 @@
-function matchInfoFactory () {
-  var info = document.createElement('div');
-  info.className = 'matchinfo';
-  info.innerHTML = 
-    "  <div class=\"matchtable\">" +
+function matchTableFactory () {
+  var table = document.createElement('div');
+  table.className = 'matchtable';
+  table.innerHTML = 
     "    <table>" +
     "      <thead>" +
     "        <tr>" +
@@ -36,17 +35,17 @@
     "        </tr>" +
     "      </tbody>" +
     "    </table>" +
-    "  </div>" +
-    "</div>";
+    "  </div>";
 
-  return info;
+  var info = document.createElement('div');
+  info.appendChild(table);
+  return table;
 };
 
-function matchInfoComplexFactory () {
-  var info = document.createElement('div');
-  info.className = 'matchinfo';
-  info.innerHTML = 
-    "  <div class=\"matchtable\">" +
+function matchTableComplexFactory () {
+  var table = document.createElement('div');
+  table.className = 'matchtable';
+  table.innerHTML = 
     "    <table>" +
     "      <thead>" +
     "        <tr>" +
@@ -84,9 +83,10 @@
     "          <td>NN</td>" +
     "        </tr>" +
     "      </tbody>" +
-    "    </table>" +
-    "  </div>";
-  return info;
+    "    </table>";
+  var info = document.createElement('div');
+  info.appendChild(table);
+  return table;
 };
 
 
@@ -107,20 +107,13 @@
         }
       ).toThrow(new Error("Requires element"));
 
-      expect(
-	      function() {
-          var minfo = document.createElement('div');
-          qcClass.create(minfo);
-        }
-      ).toThrow(new Error("Element contains no match table"));
-
-      expect(qcClass.create(matchInfoFactory()).toString()).toEqual("");
+      expect(qcClass.create(matchTableFactory()).toString()).toEqual("");
     });
 
     it('should listen to click events', function () {
 
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
       // Nothing to show
       expect(qc.toString()).toEqual("");
@@ -130,7 +123,7 @@
       expect(qc.element().className).toEqual("queryfragment");
 
       // Click on cell 0:0 "Foundry"
-      var cell = matchInfo.querySelector("thead > tr > th:first-child");
+      var cell = matchTable.querySelector("thead > tr > th:first-child");
       expect(cell.innerText).toEqual("Foundry");
       cell.click();
       expect(cell.classList.contains("chosen")).toBe(false);
@@ -138,7 +131,7 @@
       expect(qc.shown()).toBe(false);
 
       // Click on cell 0:2 "Der"
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(3)")
+      cell = matchTable.querySelector("thead > tr > th:nth-child(3)")
       expect(cell.innerText).toEqual("Der");
       cell.click();
       expect(cell.classList.contains("chosen")).toBeTruthy();
@@ -146,7 +139,7 @@
       expect(qc.shown()).toBeTruthy();
 
       // Click on cell 0:2 "Der" again - to hide
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(3)")
+      cell = matchTable.querySelector("thead > tr > th:nth-child(3)")
       expect(cell.innerText).toEqual("Der");
       cell.click();
       expect(cell.classList.contains("chosen")).toBe(false);
@@ -155,74 +148,74 @@
     });
 
     it('should create tokens in arbitrary order', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
-      var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
+      var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(4)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(4)");
       expect(cell.innerText).toEqual("älteste");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]");
 
-      cell = matchInfo.querySelector("tbody > tr > td:nth-child(4)");
+      cell = matchTable.querySelector("tbody > tr > td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
       cell.click();
       expect(qc.toString()).toEqual("[corenlp/p=ADJA & opennlp/p=ADJA & orth=älteste]");
     });
 
     it('should create token sequences in arbitrary order', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
-      var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
+      var cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
       expect(cell.innerText).toEqual("lebende");
       cell.click();
       expect(qc.toString()).toEqual("[orth=lebende]");
 
-      cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(3)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(3)");
       expect(cell.innerText).toEqual("ART");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ART][][orth=lebende]");
 
-      cell = matchInfo.querySelector("tbody > tr > td:nth-child(4)");
+      cell = matchTable.querySelector("tbody > tr > td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ART][corenlp/p=ADJA][orth=lebende]");
     });
 
     it('should remove chosen elements again', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
-      var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
+      var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
       var cell1 = cell;
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(4)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(4)");
       expect(cell.innerText).toEqual("älteste");
       cell.click();
       expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]");
       var cell2 = cell;
 
-      cell = matchInfo.querySelector("tbody > tr > td:nth-child(3)");
+      cell = matchTable.querySelector("tbody > tr > td:nth-child(3)");
       expect(cell.innerText).toEqual("ART");
       cell.click();
       expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste]");
       var cell3 = cell;
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(6)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(6)");
       expect(cell.innerText).toEqual("Baum");
       cell.click();
       expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][][orth=Baum]");
       var cell4 = cell;
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
       expect(cell.innerText).toEqual("lebende");
       cell.click();
       expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][orth=lebende][orth=Baum]");
@@ -280,8 +273,8 @@
     });
 
     it('should ignore empty terms', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
       // Nothing to show
       expect(qc.toString()).toEqual("");
@@ -290,14 +283,14 @@
       expect(qc.shown()).toBe(false);
       expect(qc.element().className).toEqual("queryfragment");
 
-      var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
+      var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
       expect(cell.classList.contains("chosen")).toBeTruthy();
       expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
 
-      cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(5)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(5)");
       expect(cell.innerText).toEqual("");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -307,8 +300,8 @@
     });
 
     it('should create or-groups for alternative terms', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
       // Nothing to show
       expect(qc.toString()).toEqual("");
@@ -317,14 +310,14 @@
       expect(qc.shown()).toBe(false);
       expect(qc.element().className).toEqual("queryfragment");
 
-      var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
+      var cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
       expect(cell.innerText).toEqual("lebende");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
       expect(cell.classList.contains("chosen")).toBeTruthy();
       expect(qc.toString()).toEqual("[orth=lebende]");
 
-      cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(5)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(5)");
       expect(cell.innerText).toEqual("ADJAADJD");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -340,8 +333,8 @@
 
 
     it('should add whole rows', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
       // Nothing to show
       expect(qc.toString()).toEqual("");
@@ -350,7 +343,7 @@
       expect(qc.shown()).toBe(false);
       expect(qc.element().className).toEqual("queryfragment");
 
-      var corenlpRow = matchInfo.querySelector("tbody > tr:nth-child(1)");
+      var corenlpRow = matchTable.querySelector("tbody > tr:nth-child(1)");
 
       var cell = corenlpRow.querySelector("td:nth-child(4)");
       expect(cell.innerText).toEqual("ADJA");
@@ -359,7 +352,7 @@
       expect(cell.classList.contains("chosen")).toBeTruthy();
 
       // Activate another cell in another row
-      cell = matchInfo.querySelector("tbody > tr:nth-child(2) td:nth-child(3)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(2) td:nth-child(3)");
       expect(cell.innerText).toEqual("ART");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -410,11 +403,11 @@
     });
 
     it('should ignore empty terms in whole rows', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
       expect(qc.toString()).toEqual("");
 
-      var opennlpRow = matchInfo.querySelector("tbody > tr:nth-child(2)");
+      var opennlpRow = matchTable.querySelector("tbody > tr:nth-child(2)");
 
       expect(opennlpRow.querySelector("td:nth-child(3).chosen")).toBeNull();
       expect(opennlpRow.querySelector("td:nth-child(4).chosen")).toBeNull();
@@ -439,28 +432,28 @@
     });
 
     it('should support multiple distances', function () {
-      var matchInfo = matchInfoFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableFactory();
+      var qc = qcClass.create(matchTable);
 
-      var cell = matchInfo.querySelector("thead > tr > th:nth-child(3)");
+      var cell = matchTable.querySelector("thead > tr > th:nth-child(3)");
       expect(cell.innerText).toEqual("Der");
       cell.click();
       expect(qc.toString()).toEqual("[orth=Der]");
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(7)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(7)");
       expect(cell.innerText).toEqual("hier");
       cell.click();
       expect(qc.toString()).toEqual("[orth=Der][]{3}[orth=hier]");
 
-      cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
+      cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
       expect(cell.innerText).toEqual("lebende");
       cell.click();
       expect(qc.toString()).toEqual("[orth=Der][][orth=lebende][][orth=hier]");
     });
 
     it('should create and-groups for key-value terms', function () {
-      var matchInfo = matchInfoComplexFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableComplexFactory();
+      var qc = qcClass.create(matchTable);
 
       // Nothing to show
       expect(qc.toString()).toEqual("");
@@ -469,7 +462,7 @@
       expect(qc.shown()).toBe(false);
       expect(qc.element().className).toEqual("queryfragment");
 
-      var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
+      var cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
       expect(cell.innerText).toEqual("lebende");
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -477,7 +470,7 @@
       expect(qc.toString()).toEqual("[orth=lebende]");
 
       // Check complex cell
-      cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6)");
       expect(cell.innerText).toMatch(/case:nom/);
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -485,7 +478,7 @@
       expect(qc.toString()).toEqual("[orth=lebende]");
 
       // Check complex cell div
-      cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(1)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(1)");
       expect(cell.innerText).toEqual('case:nom');
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -493,7 +486,7 @@
       expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom]");
       var cell = cell;
 
-      cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(3)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(3)");
       expect(cell.innerText).toEqual('number:sg');
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -501,7 +494,7 @@
       expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom & corenlp/p=number:sg]");
       var cell2 = cell;
 
-      cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(2)");
+      cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(2)");
       expect(cell.innerText).toEqual('gender:mascgender:fem');
       expect(cell.classList.contains("chosen")).toBe(false);
       cell.click();
@@ -528,11 +521,11 @@
 
 
     it('should create rows including key-value terms', function () {
-      var matchInfo = matchInfoComplexFactory();
-      var qc = qcClass.create(matchInfo);
+      var matchTable = matchTableComplexFactory();
+      var qc = qcClass.create(matchTable);
       expect(qc.toString()).toEqual("");
 
-      var corenlpRow = matchInfo.querySelector("tbody > tr:nth-child(1)");
+      var corenlpRow = matchTable.querySelector("tbody > tr:nth-child(1)");
 
       expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeNull();
       expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeNull();