Add rewrite test as method to vc
Change-Id: I87ac48fdbf9d4c75ce09c4456460d1ede56b9034
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 81e3f8a..87442bd 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -1594,6 +1594,61 @@
vc = vcClass.create().fromJson({"@type" : "koral:doc", "key" : "author", "value" : "Peter"});
expect(vc.getName()).toEqual(KorAP.Locale.VC_oneCollection);
});
+
+ it('should check for rewrites', function () {
+
+ var vc = vcClass.create().fromJson({
+ "@type" : "koral:doc",
+ "key" : "author",
+ "value" : "Goethe",
+ "rewrites" : [{
+ "@type" : "koral:rewrite",
+ "operation" : "operation:modification",
+ "src" : "querySerializer",
+ "scope" : "value"
+ }]
+ });
+ expect(vc.wasRewritten()).toBeTruthy();
+
+ var nested = {
+ "@type" : "koral:docGroup",
+ "operation" : "operation:or",
+ "operands" : [
+ {
+ "@type" : "koral:doc",
+ "key" : "author",
+ "value" : "Goethe"
+ },
+ {
+ "@type" : "koral:docGroup",
+ "operation" : "operation:and",
+ "operands" : [
+ {
+ "@type": "koral:doc",
+ "key" : "author",
+ "value" : "Schiller"
+ },
+ {
+ "@type": "koral:doc",
+ "key" : "author",
+ "value" : "Fontane"
+ }
+ ]
+ }
+ ]
+ };
+ vc = vcClass.create().fromJson(nested);
+ expect(vc.wasRewritten()).toBe(false);
+
+ nested["operands"][1]["operands"][1]["rewrites"] = [{
+ "@type" : "koral:rewrite",
+ "operation" : "operation:modification",
+ "src" : "querySerializer",
+ "scope" : "tree"
+ }];
+ vc = vcClass.create().fromJson(nested);
+ expect(vc.wasRewritten()).toBeTruthy();
+ });
});
@@ -2318,7 +2373,9 @@
});
// Check class method
- describe('KorAP.VC.checkRewrite', function () {
+ xdescribe('KorAP.VC.checkRewrite', function () {
+
+ // Class method is deprecated!
it('should check for simple rewrites', function () {
expect(vcClass.checkRewrite(