plugeth/test/utils.filters.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-01-28 13:39:10 +00:00
var assert = require('assert');
2015-01-31 14:22:05 +00:00
var utils = require('../lib/utils.js');
2015-01-28 13:39:10 +00:00
2015-01-31 14:22:05 +00:00
describe('utils', function() {
2015-01-28 13:39:10 +00:00
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
2015-01-31 14:22:05 +00:00
var events = utils.filterEvents(description);
var functions = utils.filterFunctions(description);
2015-01-28 13:39:10 +00:00
// then
assert.equal(events.length, 1);
assert.equal(events[0].name, 'test2');
assert.equal(functions.length, 1);
assert.equal(functions[0].name, 'test');
});
});