Fix replacement of docs with docgrouprefs in VC builder
Change-Id: Ib6c594dc244b1b672a4ce5c1e3afab233f47fd8c
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index ef033ab..33953b5 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -827,7 +827,7 @@
});
- it('should be replaceable by a docGroupRef', function () {
+ it('should be replaceable by docGroupRef with deletion', function () {
var vc = vcClass.create().fromJson({
"@type" : "koral:doc",
"key":"Titel",
@@ -854,9 +854,82 @@
expect(vcE.firstChild.firstChild.textContent).toEqual("referTo");
expect(vcE.firstChild.children[1].getAttribute("data-type")).toEqual("string");
+
expect(vcE.firstChild.children.length).toEqual(3);
expect(vcE.firstChild.children[1].classList.contains("unspecified")).toBeTruthy();
});
+
+
+ it('should be replaceable by docGroupRef on root', function () {
+ var vc = vcClass.create().fromJson({
+ "@type" : "koral:doc",
+ "key":"Titel",
+ "value":"Baum",
+ "match":"match:eq"
+ });
+
+ expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
+
+ var vcE = vc.builder();
+ expect(vcE.firstChild.children.length).toEqual(4);
+
+ // Click on the key
+ vcE.firstChild.firstChild.click();
+
+ expect(vcE.firstChild.getElementsByTagName("LI")[0].textContent).toEqual("referTo");
+
+ // Click on referTo
+ vcE.firstChild.getElementsByTagName("LI")[0].click();
+
+ // Now it's a referTo element
+ expect(vcE.firstChild.firstChild.textContent).toEqual("referTo");
+ expect(vcE.firstChild.children.length).toEqual(3);
+ expect(vcE.firstChild.children[1].classList.contains("unspecified")).toBeTruthy();
+ });
+
+ it('should be replaceable by docGroupRef nested', function () {
+ var vc = vcClass.create().fromJson({
+ "@type" : "koral:docGroup",
+ "operation" : "operation:and",
+ "operands" : [
+ {
+ "@type": 'koral:doc',
+ "key" : 'author',
+ "match": 'match:eq',
+ "value": 'Max Birkendale',
+ "type": 'type:string'
+ },
+ {
+ "@type": 'koral:doc',
+ "key": 'pubDate',
+ "match": 'match:eq',
+ "value": '2014-12-05',
+ "type": 'type:date'
+ }
+ ]
+ });
+
+ expect(vc.toQuery()).toEqual("author = \"Max Birkendale\" & pubDate in 2014-12-05");
+
+ var vcE = vc.builder();
+
+ // First doc
+ var doc = vcE.firstChild.firstChild;
+ expect(doc.children.length).toEqual(4);
+
+ // Click on the key
+ doc.firstChild.click();
+
+ expect(doc.getElementsByTagName("LI")[0].textContent).toEqual("referTo");
+
+ // Click on referTo
+ vcE.firstChild.getElementsByTagName("LI")[0].click();
+
+ // Now it's a referTo element
+ expect(vcE.firstChild.firstChild.firstChild.textContent).toEqual("referTo");
+ expect(vcE.firstChild.firstChild.children.length).toEqual(3);
+ expect(vcE.firstChild.firstChild.children[1].classList.contains("unspecified")).toBeTruthy();
+ });
});
describe('KorAP.DocGroup element', function () {