
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
event-store-projection-testing
Advanced tools
Test utility for Event Store projections
Add utility to projection
var fromAll = fromAll || require('event-store-projection-testing').scope.fromAll;
var emit = emit || require('event-store-projection-testing').scope.emit;
fromAll()
.when({...});
Start testing
require('chai').should();
var projection = require('event-store-projection-testing');
require('./projection');
describe('Projection tests', function () {
beforeEach(function () {
projection.initialize();
});
it('should increment balance on cashDeposited event when initial balance is set', function () {
projection.setState({ balance: 10 });
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.getState().balance.should.equal(20);
});
it('should increment balance on cashDeposited event without initial balance', function () {
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.getState().balance.should.equal(10);
});
it('should not increment balance on unregistered event', function () {
projection.processEvent('stream-123', 'NON_EXISTING_EVENT_TYPE', { deposit: 10 });
projection.getState().balance.should.equal(0);
});
it('should increment counter for every event', function () {
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.processEvent('stream-123', 'NON_EXISTING_EVENT_TYPE', { deposit: 10 });
projection.getState().counter.should.equal(2);
});
it('should remember last correlationId from metadata', function () {
expect(projection.getState().lastCorrelationId).to.be.null;
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 }, { correlationId: 1 });
projection.getState().lastCorrelationId.should.equal(1);
projection.processEvent('stream-456', 'cashDeposited', { deposit: 20 }, { correlationId: 2 });
projection.getState().lastCorrelationId.should.equal(2);
});
it('should re-emit all cashDeposited events', function () {
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.emittedEvents.should.have.length(3);
});
it('should transformBy', function () {
projection.processEvent('stream-123', 'cashDeposited', { deposit: 10 });
projection.getState().balance.should.equal(10);
projection.getTransform().transformed.should.true;
});
});
FAQs
Test utility for Event Store projections
The npm package event-store-projection-testing receives a total of 74 weekly downloads. As such, event-store-projection-testing popularity was classified as not popular.
We found that event-store-projection-testing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.