Commit 9bb5cdfc authored by Hardik Juneja's avatar Hardik Juneja

Improve performance and make build query use new functions

parent 2ca6c591
This diff is collapsed.
...@@ -428,7 +428,7 @@ ...@@ -428,7 +428,7 @@
}); });
}); });
test("get with property and its value mapped using regex", function () { test("get with property ad value mapped using regex and switch", function () {
stop(); stop();
expect(2); expect(2);
...@@ -439,10 +439,16 @@ ...@@ -439,10 +439,16 @@
}, },
mapping_dict: { mapping_dict: {
"title": { "title": {
"equal": "someTitle",
"value": { "value": {
"otherFoo": { "switch": {
"regex": "foo.*|bar.*", "foo": {
"default_value": "otherFoo" "regex": "other.*",
"default_value": "otherFoo"
},
"bar": {
"equal": "otherBar"
}
} }
} }
} }
...@@ -451,13 +457,13 @@ ...@@ -451,13 +457,13 @@
Storage2713.prototype.get = function (id) { Storage2713.prototype.get = function (id) {
equal(id, "42", "get 2713 called"); equal(id, "42", "get 2713 called");
return {"title": "otherFoo", "smth": "bar"}; return {"someTitle": "otherFoo", "smth": "bar"};
}; };
jio.get("42") jio.get("42")
.push(function (result) { .push(function (result) {
deepEqual(result, { deepEqual(result, {
"title": "otherFoo", "title": "foo",
"smth": "bar" "smth": "bar"
}); });
}).push(undefined, function (error) { }).push(undefined, function (error) {
...@@ -832,9 +838,55 @@ ...@@ -832,9 +838,55 @@
"title": { "title": {
"equal": "someTitle", "equal": "someTitle",
"value": { "value": {
"otherFoo": { "foo": {
"regex": "foo.*|bar.*", "regex": "foo.*|bar.*",
"use": "otherFoo" "default_value": "otherFoo"
}
}
}
}
});
Storage2713.prototype.put = function (id, doc) {
deepEqual(doc,
{"someTitle": "otherFoo", "smth": "bar"}, "post 2713 called");
equal(id, "42", "put 2713 called");
return id;
};
jio.put("42", {"title": "foo", "smth": "bar"})
.push(function (result) {
equal(result, "42");
})
.push(undefined, function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
test("put with property, value mapped using regex and switch", function () {
stop();
expect(3);
var jio = jIO.createJIO({
type: "mapping",
sub_storage: {
type: "mappingstorage2713"
},
mapping_dict: {
"title": {
"equal": "someTitle",
"value": {
"switch": {
"foo": {
"regex": "other.*",
"default_value": "otherFoo"
},
"bar": {
"equal": "otherBar"
}
} }
} }
} }
...@@ -848,7 +900,7 @@ ...@@ -848,7 +900,7 @@
return id; return id;
}; };
jio.put("42", {"title": "foo1", "smth": "bar"}) jio.put("42", {"title": "foo", "smth": "bar"})
.push(function (result) { .push(function (result) {
equal(result, "42"); equal(result, "42");
}) })
...@@ -1732,11 +1784,9 @@ ...@@ -1732,11 +1784,9 @@
deepEqual( deepEqual(
result, result,
[{ [{
"id": "foo",
"title": "bar", "title": "bar",
"bar": "foo" "bar": "foo"
}, { }, {
"id": "bar",
"title": "foo", "title": "foo",
"foo": "bar" "foo": "bar"
}], }],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment