node-sagas
Version:
Library for handling distributed transactions in the microservices architecture
32 lines • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const step_1 = require("../step");
const saga_params_1 = require("./saga-params");
describe('Step', () => {
test('construct', () => {
const step = new step_1.Step();
expect(step).toBeInstanceOf(step_1.Step);
});
test('getName', () => {
const stepName = 'My step';
const step = new step_1.Step(stepName);
expect(step.getName()).toEqual(stepName);
});
test('invoke', async () => {
const step = new step_1.Step();
const invocationMethod = jest.fn();
step.setInvocation(invocationMethod);
const params = new saga_params_1.SagaParams();
await step.invoke(params);
expect(invocationMethod).toHaveBeenCalledWith(params);
});
test('compensation', async () => {
const step = new step_1.Step();
const compensationMethod = jest.fn();
step.setCompensation(compensationMethod);
const params = new saga_params_1.SagaParams();
await step.compensate(params);
expect(compensationMethod).toHaveBeenCalledWith(params);
});
});
//# sourceMappingURL=step.spec.js.map