aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils.filters.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils.filters.js')
-rw-r--r--test/utils.filters.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/utils.filters.js b/test/utils.filters.js
new file mode 100644
index 000000000..f2d2788b0
--- /dev/null
+++ b/test/utils.filters.js
@@ -0,0 +1,49 @@
+var assert = require('assert');
+var utils = require('../lib/utils.js');
+
+describe('utils', function() {
+ it('should filter functions and events from input array properly', function () {
+
+ // given
+ var description = [{
+ "name": "test",
+ "type": "function",
+ "inputs": [{
+ "name": "a",
+ "type": "uint256"
+ }
+ ],
+ "outputs": [
+ {
+ "name": "d",
+ "type": "uint256"
+ }
+ ],
+ }, {
+ "name": "test2",
+ "type": "event",
+ "inputs": [{
+ "name": "a",
+ "type": "uint256"
+ }
+ ],
+ "outputs": [
+ {
+ "name": "d",
+ "type": "uint256"
+ }
+ ]
+ }];
+
+ // when
+ var events = utils.filterEvents(description);
+ var functions = utils.filterFunctions(description);
+
+ // then
+ assert.equal(events.length, 1);
+ assert.equal(events[0].name, 'test2');
+ assert.equal(functions.length, 1);
+ assert.equal(functions[0].name, 'test');
+
+ });
+});