UNPKG

@eagleeye-solutions/integration-events-common

Version:
169 lines 6.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const src_1 = require("../../../src"); const fixtures_1 = require("../../fixtures"); const mockLogger = { debug: jest.fn(), info: jest.fn(), error: jest.fn(), }; describe('getPosConnectWalletRefundEventData', () => { it.each([ { eventName: 'POSCONNECT.WALLET.REFUND (partial)', event: fixtures_1.sampleEvents.POSCONNECT_WALLET_REFUND_PARTIAL, expectedOutput: { points: { pointsBalance: 1371, }, tier: { tierId: '177', tierBalancesPoints: 171, tierBalancesSpend: 14100, tierBalancesTransactions: 0, tierBalancesResetDate: new Date('2031-01-31T23:59:59.000Z'), }, currencyCode: 'USD', redeemedCoupons: [ { accountId: '4126000957', campaignId: '100792525', type: 'ECOUPON', clientType: 'OFFER', state: 'LOADED', status: 'USED', dateStart: new Date('2025-02-10T21:59:36.000Z'), dateEnd: new Date('2025-02-10T22:00:58.000Z'), value: 500, }, ], unredeemedCoupons: [ { accountId: '4126000957', campaignId: '100792525', type: 'ECOUPON', clientType: 'OFFER', state: 'LOADED', status: 'ACTIVE', dateStart: new Date('2025-02-10T21:59:36.000Z'), dateEnd: new Date('2025-02-10T22:00:58.000Z'), value: 700, }, ], transaction: { products: [ { description: 'Lemonade', itemUnitCost: 1000, itemUnitCount: 2, totalUnitCost: 2000, totalUnitCostAfterDiscount: 2000, upc: '245874', }, ], storeLocation: { storeId: 'outlet1', storeParentId: 'banner1', }, totalBasketValueAfterDiscount: 1800, totalPointsDeducted: 18, transactionReference: 'RefundTransactionReferencefeb10c', }, }, }, { eventName: 'POSCONNECT.WALLET.REFUND (full)', event: fixtures_1.sampleEvents.POSCONNECT_WALLET_REFUND_FULL, expectedOutput: { points: { pointsBalance: 1326, }, tier: { tierId: '177', tierBalancesPoints: 126, tierBalancesSpend: 12600, tierBalancesTransactions: 0, tierBalancesResetDate: new Date('2031-01-31T23:59:59.000Z'), }, currencyCode: 'USD', redeemedCoupons: [], unredeemedCoupons: [], transaction: { products: [ { description: 'Lemonade', itemUnitCost: 1000, itemUnitCount: 2, totalUnitCost: 2000, totalUnitCostAfterDiscount: 2000, upc: '245874', }, { description: 'Coffee', itemUnitCost: 1000, itemUnitCount: 1, totalUnitCost: 1000, totalUnitCostAfterDiscount: 1000, upc: '245875', }, { description: 'Oranges', itemUnitCost: 1000, itemUnitCount: 1, totalUnitCost: 1000, totalUnitCostAfterDiscount: 1000, upc: '245887', }, { description: 'Carrot', itemUnitCost: 1000, itemUnitCount: 1, totalUnitCost: 1000, totalUnitCostAfterDiscount: 1000, upc: '245886', }, { description: 'Pizza', itemUnitCost: 1000, itemUnitCount: 1, totalUnitCost: 1000, totalUnitCostAfterDiscount: 1000, upc: '245868', }, { description: 'Wine', itemUnitCost: 1000, itemUnitCount: 1, totalUnitCost: 1000, totalUnitCostAfterDiscount: 1000, upc: '245872', }, ], storeLocation: { storeId: 'outlet1', storeParentId: 'banner1', }, totalBasketValueAfterDiscount: 7000, totalPointsDeducted: 63, transactionReference: 'RefundTransactionReferencefeb10b', }, }, }, ])('handles an initial $eventName event', ({ event, expectedOutput }) => { // Arrange const eeAirOutboundEvent = src_1.EeAirOutboundEventSchema.parse(event); const configuration = { currency: 'USD', }; // Act const output = (0, src_1.getPosConnectWalletRefundEventData)(eeAirOutboundEvent, { connectorConfig: { configuration, }, logger: mockLogger, }); // Assert expect(output).toEqual(expectedOutput); }); }); //# sourceMappingURL=posconnect-wallet-refund.spec.js.map