Commit ddc17196 authored by Marek Kotewicz's avatar Marek Kotewicz

tests && fixes for utils methods

parent fdcc1af4
...@@ -1269,7 +1269,7 @@ var extractDisplayName = function (name) { ...@@ -1269,7 +1269,7 @@ var extractDisplayName = function (name) {
var extractTypeName = function (name) { var extractTypeName = function (name) {
/// TODO: make it invulnerable /// TODO: make it invulnerable
var length = name.indexOf('('); var length = name.indexOf('(');
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)) : ""; return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
}; };
/// Filters all function from input abi /// Filters all function from input abi
......
This diff is collapsed.
This diff is collapsed.
...@@ -84,7 +84,7 @@ var extractDisplayName = function (name) { ...@@ -84,7 +84,7 @@ var extractDisplayName = function (name) {
var extractTypeName = function (name) { var extractTypeName = function (name) {
/// TODO: make it invulnerable /// TODO: make it invulnerable
var length = name.indexOf('('); var length = name.indexOf('(');
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)) : ""; return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
}; };
/// Filters all function from input abi /// Filters all function from input abi
......
var assert = require('assert');
var utils = require('../lib/utils.js');
describe('utils', function () {
describe('extractDisplayName', function () {
it('should extract display name from method with no params', function () {
// given
var test = 'helloworld()';
// when
var displayName = utils.extractDisplayName(test);
// then
assert.equal(displayName, 'helloworld');
});
it('should extract display name from method with one param' , function () {
// given
var test = 'helloworld1(int)';
// when
var displayName = utils.extractDisplayName(test);
// then
assert.equal(displayName, 'helloworld1');
});
it('should extract display name from method with two params' , function () {
// given
var test = 'helloworld2(int,string)';
// when
var displayName = utils.extractDisplayName(test);
// then
assert.equal(displayName, 'helloworld2');
});
});
});
var assert = require('assert');
var utils = require('../lib/utils.js');
describe('utils', function () {
describe('extractTypeName', function () {
it('should extract type name from method with no params', function () {
// given
var test = 'helloworld()';
// when
var typeName = utils.extractTypeName(test);
// then
assert.equal(typeName, '');
});
it('should extract type name from method with one param', function () {
// given
var test = 'helloworld1(int)';
// when
var typeName = utils.extractTypeName(test);
// then
assert.equal(typeName, 'int');
});
it('should extract type name from method with two params', function () {
// given
var test = 'helloworld2(int,string)';
// when
var typeName = utils.extractTypeName(test);
// then
assert.equal(typeName, 'int,string');
});
it('should extract type name from method with spaces between params', function () {
// given
var test = 'helloworld3(int, string)';
// when
var typeName = utils.extractTypeName(test);
// then
assert.equal(typeName, 'int,string');
});
});
});
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