Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test on message filtering

  • Loading branch information...
commit 37dd3d214bd09818bb4a6206d6655fa739d34217 1 parent 88d375c
Bertrand Paquet authored
View
3  lib/filters/filter_compute_field.js
@@ -21,6 +21,9 @@ FilterComputeField.prototype.afterLoadConfig = function(callback) {
FilterComputeField.prototype.process = function(data) {
var value = this.replaceByFields(data, this.value);
if (value) {
+ if (!data['@fields']) {
+ data['@fields'] = {};
+ }
data['@fields'][this.field_name] = value;
}
return data;
View
9 test/test_25_filter_compute_field.js
@@ -4,7 +4,14 @@ var vows = require('vows'),
filter_helper = require('./filter_helper');
vows.describe('Filter compute field ').addBatch({
- 'normal': filter_helper.create('compute_field', 'titi?value=ab#{bouh}', [
+ 'normal': filter_helper.create('compute_field', 'titi?value=ab', [
+ {'@message': 'toto'},
+ {'@message': 'toto', '@fields': {'bouh': 'tata'}},
+ ], [
+ {'@message': 'toto', '@fields': {'titi': 'ab'}},
+ {'@message': 'toto', '@fields': {'bouh': 'tata', 'titi': 'ab'}},
+ ]),
+ 'with value': filter_helper.create('compute_field', 'titi?value=ab#{bouh}', [
{'@message': 'toto'},
{'@message': 'toto', '@fields': {'bouh': 'tata'}},
{'@message': 'toto', '@fields': {'bouh': 42}},
View
21 test/test_26_message_filtering.js
@@ -0,0 +1,21 @@
+var vows = require('vows'),
+ assert = require('assert'),
+ os = require('os'),
+ filter_helper = require('./filter_helper');
+
+vows.describe('Message filtering ').addBatch({
+ 'nothing': filter_helper.create('compute_field', 'titi?value=a', [
+ {'@message': 'toto'},
+ ], [
+ {'@message': 'toto', '@fields': {'titi': 'a'}},
+ ]),
+ 'only type': filter_helper.create('compute_field', 'titi?value=a&only_type=z', [
+ {'@message': 'toto'},
+ {'@message': 'toto', '@type': 'tata'},
+ {'@message': 'toto', '@type': 'z'},
+ ], [
+ {'@message': 'toto'},
+ {'@message': 'toto', '@type': 'tata'},
+ {'@message': 'toto', '@type': 'z', '@fields': {'titi': 'a'}},
+ ]),
+}).export(module);
Please sign in to comment.
Something went wrong with that request. Please try again.