Introduce corpusByMatch assistant object
Change-Id: Ia23b644e545f9e720de89704be1dc83a79957193
diff --git a/dev/js/spec/corpusByMatchSpec.js b/dev/js/spec/corpusByMatchSpec.js
new file mode 100644
index 0000000..d2588b0
--- /dev/null
+++ b/dev/js/spec/corpusByMatchSpec.js
@@ -0,0 +1,50 @@
+/**
+ * Specification for the corpusByMatch assistant.
+ */
+
+function metaTableFactory () {
+ var meta = document.createElement('div');
+ meta.className = 'view metaTable';
+ meta.innerHTML =
+ " <dl class=\"flex\">" +
+ " <div>" +
+ " <dt title=\"author\">author</dt>" +
+ " <dd>Sprachpfleger, u.a.</dd>" +
+ " </div>" +
+ " <div>" +
+ " <dd class=\"metakeyvalues\">" +
+ " <div>corenlp</div>" +
+ " <div>corenlp/constituency</div>" +
+ " <div>corenlp/morpho</div>" +
+ " <div>corenlp/sentences</div>" +
+ " <div>dereko</div>" +
+ " <div>dereko/structure</div>" +
+ " <div>dereko/structure/base-sentences-paragraphs-pagebreaks</div>" +
+ " <div>opennlp</div>" +
+ " <div>opennlp/morpho</div>" +
+ " <div>opennlp/sentences</div>" +
+ " </dd>" +
+ " </div>" +
+ " </dl>";
+ var parent = document.createElement("div");
+ parent.appendChild(meta);
+ return meta;
+};
+
+define(['match/corpusByMatch'], function (cbmClass) {
+ describe('KorAP.CorpusByMatch', function () {
+ it('should be initializable', function () {
+ expect(function () {
+ cbmClass.create()
+ }).toThrow(new Error("Missing parameters"));
+
+ expect(
+ function() {
+ cbmClass.create("Test")
+ }
+ ).toThrow(new Error("Requires element"));
+
+ expect(cbmClass.create(metaTableFactory()).toString()).toEqual("");
+ });
+ });
+});
diff --git a/dev/js/spec/queryCreatorSpec.js b/dev/js/spec/queryCreatorSpec.js
index 21fffac..5c5cddf 100644
--- a/dev/js/spec/queryCreatorSpec.js
+++ b/dev/js/spec/queryCreatorSpec.js
@@ -2,13 +2,13 @@
* Specification for the query creator.
*/
+
+Element.prototype.innerString = function () {
+ return this.innerText.split("\n").join("");
+};
+
function matchTableFactory () {
var table = document.createElement('div');
-
- Element.prototype.innerString = function () {
- return this.innerText.split("\n").join("");
- };
-
table.className = 'matchtable';
table.innerHTML =
@@ -131,7 +131,7 @@
expect(qc.shown()).toBe(false);
qc.show();
expect(qc.shown()).toBe(false);
- expect(qc.element().className).toEqual("queryfragment");
+ expect(qc.element().className).toEqual("query fragment");
// Click on cell 0:0 "Foundry"
var cell = matchTable.querySelector("thead > tr > th:first-child");
@@ -292,7 +292,7 @@
expect(qc.shown()).toBe(false);
qc.show();
expect(qc.shown()).toBe(false);
- expect(qc.element().className).toEqual("queryfragment");
+ expect(qc.element().className).toEqual("query fragment");
var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
expect(cell.innerString()).toEqual("ADJA");
@@ -319,7 +319,7 @@
expect(qc.shown()).toBe(false);
qc.show();
expect(qc.shown()).toBe(false);
- expect(qc.element().className).toEqual("queryfragment");
+ expect(qc.element().className).toEqual("query fragment");
var cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
expect(cell.innerString()).toEqual("lebende");
@@ -352,7 +352,7 @@
expect(qc.shown()).toBe(false);
qc.show();
expect(qc.shown()).toBe(false);
- expect(qc.element().className).toEqual("queryfragment");
+ expect(qc.element().className).toEqual("query fragment");
var corenlpRow = matchTable.querySelector("tbody > tr:nth-child(1)");
@@ -471,7 +471,7 @@
expect(qc.shown()).toBe(false);
qc.show();
expect(qc.shown()).toBe(false);
- expect(qc.element().className).toEqual("queryfragment");
+ expect(qc.element().className).toEqual("query fragment");
var cell = matchTable.querySelector("thead > tr > th:nth-child(5)");
expect(cell.innerString()).toEqual("lebende");