-
Notifications
You must be signed in to change notification settings - Fork 9
/
opportunity-free-idempotency-test.js
36 lines (35 loc) · 1.64 KB
/
opportunity-free-idempotency-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { omit } = require('lodash');
const { FeatureHelper } = require('../../../../helpers/feature-helper');
const { FlowStageRecipes, FlowStageUtils } = require('../../../../helpers/flow-stages');
const { Common } = require('../../../../shared-behaviours');
FeatureHelper.describeFeature(module, {
testCategory: 'payment',
testFeature: 'free-opportunities',
testFeatureImplemented: true,
testIdentifier: 'opportunity-free-idempotency',
testName: 'Successful booking of free opportunity with idempotency',
testDescription: 'Testing idempotency of the B call for free opportunities',
testOpportunityCriteria: 'TestOpportunityBookableFree',
// This must also be TestOpportunityBookableFree as the entire Order must be free.
controlOpportunityCriteria: 'TestOpportunityBookableFree',
}, (configuration, orderItemCriteriaList, featureIsImplemented, logger, describeFeatureRecord) => {
const {
fetchOpportunities,
bookRecipe,
defaultFlowStageParams,
bookRecipeArgs,
} = FlowStageRecipes.initialiseSimpleC1C2BookFlow(orderItemCriteriaList, logger, describeFeatureRecord);
const idempotentRepeatB = FlowStageRecipes.idempotentRepeatBAfterBook(
orderItemCriteriaList,
bookRecipe,
defaultFlowStageParams,
omit(bookRecipeArgs, ['prerequisite']),
);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(fetchOpportunities);
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(bookRecipe);
describe('idempotent repeat B', () => {
FlowStageUtils.describeRunAndCheckIsSuccessfulAndValid(idempotentRepeatB, () => {
Common.itIdempotentBShouldHaveOutputEqualToFirstB(bookRecipe.b, idempotentRepeatB);
});
});
});