spur-common
Version:
Common node library that is implemented through the use of spur-ioc and bluebird promises.
64 lines (49 loc) • 1.44 kB
text/coffeescript
describe "BaseDelegate", ->
beforeEach ->
= []
mockConsole =
log:(args...)=> .push(args)
injector()
.addDependency("console", mockConsole, true)
.inject ()=>
class extends
constructor:()->
[
"log", "debug"
]
it "should exist", ->
expect().to.exist
it "base delegate test", ->
delegate = new
delegate.log("hi")
delegate.debug("hello")
expect().to.deep.equal [
[ 'SomeDelegate#log: ', 'hi' ],
[ 'SomeDelegate#debug: ', 'hello' ]
]
delegate.useRecorder()
delegate.log("hi2")
delegate.debug("hello2")
expect(delegate.recorded.log).to.deep.equal [["hi2"]]
expect(delegate.recorded.debug).to.deep.equal [["hello2"]]
delegate.use({
log:()=>
debug:()=>
})
delegate.log("foo")
delegate.debug("bar")
expect().to.equal "foo"
expect().to.equal "bar"
it "multiple delegates", ->
delegate = new
delegate.delegates = [
delegate.consoleDelegate
delegate.consoleDelegate
delegate.consoleDelegate
]
delegate.log("foo")
expect().to.deep.equal [
[ 'SomeDelegate#log: ', 'foo' ],
[ 'SomeDelegate#log: ', 'foo' ],
[ 'SomeDelegate#log: ', 'foo' ]
]