eventric
Version:
Build JavaScript applications with Behaviour-driven Domain Design. Based on DDD, BDD, CQRS and EventSourcing.
26 lines (20 loc) • 974 B
text/coffeescript
describe 'Adapter Feature', ->
describe 'given we created and initialized some example context including an aggregate', ->
exampleContext = null
beforeEach ->
exampleContext = eventric.context 'exampleContext'
exampleContext.addAggregate 'Example', class Example
describe 'when we use a command which calls a previously added adapter function', ->
ExampleAdapter = null
beforeEach ->
class ExampleAdapter
someAdapterFunction: sandbox.stub()
exampleContext.addAdapter 'exampleAdapter', ExampleAdapter
exampleContext.addCommandHandler 'doSomething', (params, callback) ->
@$adapter('exampleAdapter').someAdapterFunction()
callback()
it 'then it should have called the adapter function', ->
exampleContext.initialize =>
exampleContext.command 'doSomething'
.then ->
expect(ExampleAdapter::someAdapterFunction).to.have.been.calledOnce