2015-03-22 18:48:25 +00:00
|
|
|
var chai = require('chai');
|
|
|
|
var assert = chai.assert;
|
|
|
|
var Method = require('../lib/web3/method');
|
|
|
|
var utils = require('../lib/utils/utils');
|
|
|
|
|
2015-03-25 21:17:35 +00:00
|
|
|
describe('lib/web3/method', function () {
|
2015-03-22 18:48:25 +00:00
|
|
|
describe('attachToObject', function () {
|
2015-03-26 17:11:05 +00:00
|
|
|
//it('attach simple function to an object', function () {
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// given
|
|
|
|
//var method = new Method({
|
|
|
|
//name: 'hello'
|
|
|
|
//});
|
|
|
|
//var object = {};
|
|
|
|
//var func = function () { return 1; };
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// when
|
|
|
|
//method.attachToObject(object, func);
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// then
|
|
|
|
//assert.equal(utils.isFunction(object.hello), true);
|
|
|
|
//assert.equal(object.hello(), 1);
|
|
|
|
//});
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//it('attach nested function to an object', function () {
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// given
|
|
|
|
//var method = new Method({
|
|
|
|
//name: 'hello.world'
|
|
|
|
//});
|
|
|
|
//var object = {};
|
|
|
|
//var func = function () { return 1; };
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// when
|
|
|
|
//method.attachToObject(object, func);
|
2015-03-22 18:48:25 +00:00
|
|
|
|
2015-03-26 17:11:05 +00:00
|
|
|
//// then
|
|
|
|
//assert.equal(utils.isObject(object.hello), true);
|
|
|
|
//assert.equal(utils.isFunction(object.hello.world), true);
|
|
|
|
//assert.equal(object.hello.world(), 1);
|
|
|
|
//});
|
2015-03-22 18:48:25 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|