UNPKG

eventric

Version:

Build JavaScript applications with Behaviour-driven Domain Design. Based on DDD, BDD, CQRS and EventSourcing.

45 lines (39 loc) 1.55 kB
describe('Adapter Feature', function() { return describe('given we created and initialized some example context including an aggregate', function() { var exampleContext; exampleContext = null; beforeEach(function() { var Example; exampleContext = eventric.context('exampleContext'); return exampleContext.addAggregate('Example', Example = (function() { function Example() {} return Example; })()); }); return describe('when we use a command which calls a previously added adapter function', function() { var ExampleAdapter; ExampleAdapter = null; beforeEach(function() { ExampleAdapter = (function() { function ExampleAdapter() {} ExampleAdapter.prototype.someAdapterFunction = sandbox.stub(); return ExampleAdapter; })(); exampleContext.addAdapter('exampleAdapter', ExampleAdapter); return exampleContext.addCommandHandler('doSomething', function(params, callback) { this.$adapter('exampleAdapter').someAdapterFunction(); return callback(); }); }); return it('then it should have called the adapter function', function() { return exampleContext.initialize((function(_this) { return function() { return exampleContext.command('doSomething').then(function() { return expect(ExampleAdapter.prototype.someAdapterFunction).to.have.been.calledOnce; }); }; })(this)); }); }); }); });