@eagleeye-solutions/integration-events-common
Version:
Eagle Eye CDP connector common functionality
165 lines • 8.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const zod_1 = require("zod");
const types_1 = require("../../../src/types");
const ee_air_outbound_events_1 = require("../../fixtures/ee-air-outbound-events");
describe('Eagle Eye AIR outbound event parsing', () => {
describe('Successful event parsing', () => {
it.each([
[
'POSCONNECT_WALLET_FULFIL_FINAL',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_FULFIL_FINAL'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_FULFIL_FINAL'],
],
[
'POSCONNECT_WALLET_FULFIL_INITIAL',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_FULFIL_INITIAL'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_FULFIL_INITIAL'],
],
[
'POSCONNECT_WALLET_FULFIL_MIDDLE',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_FULFIL_MIDDLE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_FULFIL_MIDDLE'],
],
[
'POSCONNECT_WALLET_OPEN',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_OPEN'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_OPEN'],
],
[
'POSCONNECT_WALLET_REFUND_FULL',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_REFUND_FULL'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_REFUND_FULL'],
],
[
'POSCONNECT_WALLET_REFUND_PARTIAL',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_REFUND_PARTIAL'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_REFUND_PARTIAL'],
],
[
'POSCONNECT_WALLET_SETTLE',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_SETTLE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_SETTLE'],
],
[
'SERVICE_TRIGGER_COUPON',
ee_air_outbound_events_1.sampleEvents['SERVICE_TRIGGER_COUPON'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SERVICE_TRIGGER_COUPON'],
],
[
'SERVICE_TRIGGER_POINTS',
ee_air_outbound_events_1.sampleEvents['SERVICE_TRIGGER_POINTS'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SERVICE_TRIGGER_POINTS'],
],
[
'SERVICE_WALLET_ACCOUNTS_CREATE',
ee_air_outbound_events_1.sampleEvents['SERVICE_WALLET_ACCOUNTS_CREATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SERVICE_WALLET_ACCOUNTS_CREATE'],
],
[
'SERVICE_WALLET_CREATE',
ee_air_outbound_events_1.sampleEvents['SERVICE_WALLET_CREATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SERVICE_WALLET_CREATE'],
],
[
'SPEND_POSCONNECT_WALLET_OPEN',
ee_air_outbound_events_1.sampleEvents['SPEND_POSCONNECT_WALLET_OPEN'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SPEND_POSCONNECT_WALLET_OPEN'],
],
[
'SPEND_POSCONNECT_WALLET_SPEND',
ee_air_outbound_events_1.sampleEvents['SPEND_POSCONNECT_WALLET_SPEND'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SPEND_POSCONNECT_WALLET_SPEND'],
],
[
'SPEND_POSCONNECT_WALLET_SPEND_VOID',
ee_air_outbound_events_1.sampleEvents['SPEND_POSCONNECT_WALLET_SPEND_VOID'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SPEND_POSCONNECT_WALLET_SPEND_VOID'],
],
[
'SPEND_POSCONNECT_WALLET_SETTLE',
ee_air_outbound_events_1.sampleEvents['SPEND_POSCONNECT_WALLET_SETTLE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['SPEND_POSCONNECT_WALLET_SETTLE'],
],
[
'TIER_MEMBERSHIP_ADJUST_NEGATIVE',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_ADJUST_NEGATIVE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_ADJUST_NEGATIVE'],
],
[
'TIER_MEMBERSHIP_ADJUST_POSITIVE',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_ADJUST_POSITIVE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_ADJUST_POSITIVE'],
],
[
'TIER_MEMBERSHIP_CREATE',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_CREATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_CREATE'],
],
[
'TIER_MEMBERSHIP_CREDIT',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_CREDIT'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_CREDIT'],
],
[
'TIER_MEMBERSHIP_DEBIT',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_DEBIT'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_DEBIT'],
],
[
'TIER_MEMBERSHIP_MOVE',
ee_air_outbound_events_1.sampleEvents['TIER_MEMBERSHIP_MOVE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['TIER_MEMBERSHIP_MOVE'],
],
[
'WALLET_ACCOUNT_CREATE_CAMPAIGN_MULTIPLE',
ee_air_outbound_events_1.sampleEvents['WALLET_ACCOUNT_CREATE_CAMPAIGN_MULTIPLE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_ACCOUNT_CREATE_CAMPAIGN_MULTIPLE'],
],
[
'WALLET_ACCOUNT_CREATE_CAMPAIGN_SINGLE',
ee_air_outbound_events_1.sampleEvents['WALLET_ACCOUNT_CREATE_CAMPAIGN_SINGLE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_ACCOUNT_CREATE_CAMPAIGN_SINGLE'],
],
[
'WALLET_ACCOUNT_CREATE_PLAN',
ee_air_outbound_events_1.sampleEvents['WALLET_ACCOUNT_CREATE_PLAN'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_ACCOUNT_CREATE_PLAN'],
],
[
'WALLET_ACCOUNT_CREATE_SCHEME',
ee_air_outbound_events_1.sampleEvents['WALLET_ACCOUNT_CREATE_SCHEME'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_ACCOUNT_CREATE_SCHEME'],
],
[
'WALLET_ACCOUNT_UPDATE',
ee_air_outbound_events_1.sampleEvents['WALLET_ACCOUNT_UPDATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_ACCOUNT_UPDATE'],
],
[
'WALLET_CONSUMER_CREATE',
ee_air_outbound_events_1.sampleEvents['WALLET_CONSUMER_CREATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_CONSUMER_CREATE'],
],
[
'WALLET_CONSUMER_UPDATE',
ee_air_outbound_events_1.sampleEvents['WALLET_CONSUMER_UPDATE'],
ee_air_outbound_events_1.expectedParsedSampleEvents['WALLET_CONSUMER_UPDATE'],
],
[
'POSCONNECT_WALLET_REFUND_TEST_01',
ee_air_outbound_events_1.sampleEvents['POSCONNECT_WALLET_REFUND_TEST_01'],
ee_air_outbound_events_1.expectedParsedSampleEvents['POSCONNECT_WALLET_REFUND_TEST_01'],
],
])('parses an %s successfully', (_eventName, sampleEvent, expectedParsedSampleEvent) => {
const parsedEvent = types_1.EeAirOutboundEventSchema.parse(sampleEvent);
expect(parsedEvent).toEqual(expectedParsedSampleEvent);
});
});
describe('Parsing of invalid events', () => {
it('throws an error if enrichment data is missing from a TIER_MEMBERSHIP_CREATE', () => {
expect(() => types_1.EeAirOutboundEventSchema.parse(ee_air_outbound_events_1.sampleEvents['INVALID_TIER_MEMBERSHIP_CREATE_NO_ENRICHMENT_DATA'])).toThrow(zod_1.z.ZodError);
});
});
});
//# sourceMappingURL=event-parsing.spec.js.map