Add addProxy() method to Adaptor class
This commit is contained in:
parent
1209686388
commit
9452739244
|
@ -11,3 +11,6 @@
|
|||
module.exports = class Adaptor
|
||||
constructor: (opts) ->
|
||||
@name = opts.name
|
||||
|
||||
addProxy: (object, method) ->
|
||||
this[method] = (args...) -> object[method](args...)
|
||||
|
|
|
@ -11,3 +11,15 @@ describe "Adaptor", ->
|
|||
|
||||
it "should be able to connect"
|
||||
it "should be able to disconnect"
|
||||
|
||||
it 'can alias methods with addProxy()', ->
|
||||
proxyObject = { toString: -> "[object ProxyObject]" }
|
||||
adaptor.addProxy(proxyObject, 'toString')
|
||||
assert typeof adaptor.toString is 'function'
|
||||
adaptor.toString().should.be.equal "[object ProxyObject]"
|
||||
|
||||
it 'can alias methods with arguments with addProxy()', ->
|
||||
proxyObject = { returnString: (string) -> string }
|
||||
adaptor.addProxy(proxyObject, 'returnString')
|
||||
assert typeof adaptor.returnString is 'function'
|
||||
adaptor.returnString("testString").should.be.equal "testString"
|
||||
|
|
Loading…
Reference in New Issue