Replace minimal groups
diff --git a/public/js/spec/vcSpec.js b/public/js/spec/vcSpec.js
index 2010adf..aa57b4f 100644
--- a/public/js/spec/vcSpec.js
+++ b/public/js/spec/vcSpec.js
@@ -628,9 +628,55 @@
expect(second.matchop()).toEqual('eq');
});
+
it('should be based on a nested docGroup', function () {
var vc = KorAP.VirtualCollection.render({
"@type" : "korap:docGroup",
+ "operation" : "operation:or",
+ "operands" : [
+ {
+ "@type": 'korap:doc',
+ "key" : 'author',
+ "match": 'match:eq',
+ "value": 'Max Birkendale',
+ "type": 'type:string'
+ },
+ {
+ "@type" : "korap:docGroup",
+ "operation" : "operation:and",
+ "operands" : [
+ {
+ "@type": 'korap:doc',
+ "key": 'pubDate',
+ "match": 'match:geq',
+ "value": '2014-05-12',
+ "type": 'type:date'
+ },
+ {
+ "@type": 'korap:doc',
+ "key": 'pubDate',
+ "match": 'match:leq',
+ "value": '2014-12-05',
+ "type": 'type:date'
+ }
+ ]
+ }
+ ]
+ });
+ expect(vc.element().getAttribute('class')).toEqual('vc');
+ expect(vc.element().firstChild.getAttribute('class')).toEqual('docGroup');
+ expect(vc.element().firstChild.children[0].getAttribute('class')).toEqual('doc');
+ var dg = vc.element().firstChild.children[1];
+ expect(dg.getAttribute('class')).toEqual('docGroup');
+ expect(dg.children[0].getAttribute('class')).toEqual('doc');
+ expect(dg.children[1].getAttribute('class')).toEqual('doc');
+ expect(dg.children[2].getAttribute('class')).toEqual('operators');
+ expect(vc.element().firstChild.children[2].getAttribute('class')).toEqual('operators');
+ });
+
+ it('should be modifiable by deletion', function () {
+ var vc = KorAP.VirtualCollection.render({
+ "@type" : "korap:docGroup",
"operation" : "operation:and",
"operands" : [
{
@@ -660,39 +706,21 @@
var docGroup = vc.root();
var doc = docGroup.getOperand(1);
expect(doc.key()).toEqual("pubDate");
- expect(docGroup.delOperand(doc)).toEqual(true);
+
+ // Remove operand 1
+ expect(docGroup.delOperand(doc)).not.toBeUndefined();
+ expect(doc._element).toEqual(undefined);
+
doc = docGroup.getOperand(1);
expect(doc.key()).toEqual("foo");
- });
- it('should be modifiable', function () {
- var vc = KorAP.VirtualCollection.render();
+ // Remove operand 1
+ expect(docGroup.delOperand(doc)).not.toBeUndefined();
+ expect(doc._element).toEqual(undefined);
- var vc = KorAP.VirtualCollection.render({
- "@type" : "korap:docGroup",
- "operation" : "operation:and",
- "operands" : [
- {
- "@type": 'korap:doc',
- "key" : 'author',
- "match": 'match:eq',
- "value": 'Max Birkendale',
- "type": 'type:string'
- },
- {
- "@type": 'korap:doc',
- "key": 'pubDate',
- "match": 'match:eq',
- "value": '2014-12-05',
- "type": 'type:date'
- }
- ]
- });
-
- expect(vc.element().getAttribute('class')).toEqual('vc');
- expect(vc.root().element().getAttribute('class')).toEqual('docGroup');
- expect(vc.root().operation()).toEqual('and');
- });
+ // Only one operand - but there shouldn't be a group anymore!
+ expect(docGroup.getOperand(1)).toBeUndefined();
+ });
});
describe('KorAP.Operators', function () {