UNPKG

eventric-testing

Version:
120 lines (108 loc) 4.2 kB
var aggregateFactory, commandQueryFactory, domainEventFactory, eventric, fakePromise, projectionFactory, remoteFactory, stubFactory, wiredRemotes, slice = [].slice; eventric = require('eventric'); stubFactory = require('./stub_factory'); aggregateFactory = require('./aggregate_factory'); fakePromise = require('./fake_promise'); commandQueryFactory = require('./command_query_factory'); projectionFactory = require('./projection_factory'); remoteFactory = require('./remote_factory'); domainEventFactory = require('./domain_event_factory'); wiredRemotes = []; eventric.testing = { setStubMethods: function(stubMethod, configureReturnValueMethod) { stubFactory.setStubMethod(stubMethod); return stubFactory.setConfigureReturnValueMethod(configureReturnValueMethod); }, resolve: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return fakePromise.resolve.apply(fakePromise, args); }, reject: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return fakePromise.reject.apply(fakePromise, args); }, resolveAsync: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return fakePromise.resolveAsync.apply(fakePromise, args); }, rejectAsync: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return fakePromise.rejectAsync.apply(fakePromise, args); }, fakeAggregate: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return aggregateFactory.fakeAggregate.apply(aggregateFactory, args); }, wiredAggregate: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return aggregateFactory.wiredAggregate.apply(aggregateFactory, args); }, wiredCommandHandler: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.wiredCommandHandler.apply(commandQueryFactory, args); }, wiredQueryHandler: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.wiredQueryHandler.apply(commandQueryFactory, args); }, wiredProjection: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return projectionFactory.wiredProjection.apply(projectionFactory, args); }, aggregateStub: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.aggregateStub.apply(commandQueryFactory, args); }, wiredRemote: function() { var args, wiredRemote; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; wiredRemote = remoteFactory.wiredRemote.apply(remoteFactory, args); wiredRemotes.push(wiredRemote); return wiredRemote; }, projectionStoreMongoDbStub: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return projectionFactory.mongoDbStoreStub.apply(projectionFactory, args); }, createDomainEvent: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return domainEventFactory.createDomainEvent.apply(domainEventFactory, args); }, destroy: function() { var i, len, wiredRemote; for (i = 0, len = wiredRemotes.length; i < len; i++) { wiredRemote = wiredRemotes[i]; wiredRemote.$destroy(); } return wiredRemotes = []; }, waitForQueryToReturnResult: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.waitForQueryToReturnResult.apply(commandQueryFactory, args); }, waitForCommandToResolve: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.waitForCommandToResolve.apply(commandQueryFactory, args); }, waitForResult: function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return commandQueryFactory.waitForResult.apply(commandQueryFactory, args); } }; module.exports = eventric.testing;