|
1 | 1 | import packageJson from '../../package.json'; |
2 | 2 | const packageVersion = packageJson.version; |
3 | 3 | import '../../src/Rokt-Kit'; |
| 4 | +import { |
| 5 | + isSelectPlacementsAttributePersistenceDenied, |
| 6 | + removeSelectPlacementsAttributePersistenceDeniedAttributes, |
| 7 | +} from '../../src/Rokt-Kit'; |
4 | 8 | import { Batch } from '@mparticle/web-sdk/internal'; |
5 | 9 |
|
6 | 10 | /* eslint-disable @typescript-eslint/no-explicit-any */ |
@@ -6107,6 +6111,50 @@ describe('Rokt Forwarder', () => { |
6107 | 6111 | }); |
6108 | 6112 | }); |
6109 | 6113 |
|
| 6114 | + describe('#isSelectPlacementsAttributePersistenceDenied', () => { |
| 6115 | + it('should identify denylisted attributes case-insensitively', () => { |
| 6116 | + expect(isSelectPlacementsAttributePersistenceDenied('confirmationref')).toBe(true); |
| 6117 | + expect(isSelectPlacementsAttributePersistenceDenied('confirmationRef')).toBe(true); |
| 6118 | + expect(isSelectPlacementsAttributePersistenceDenied('CONFIRMATIONREF')).toBe(true); |
| 6119 | + expect(isSelectPlacementsAttributePersistenceDenied('paymentServiceProvider')).toBe(true); |
| 6120 | + expect(isSelectPlacementsAttributePersistenceDenied('cartItems')).toBe(true); |
| 6121 | + expect(isSelectPlacementsAttributePersistenceDenied('conversionType')).toBe(true); |
| 6122 | + }); |
| 6123 | + |
| 6124 | + it('should return false for attributes that are not denylisted', () => { |
| 6125 | + expect(isSelectPlacementsAttributePersistenceDenied('loyaltyTier')).toBe(false); |
| 6126 | + expect(isSelectPlacementsAttributePersistenceDenied('favoriteStore')).toBe(false); |
| 6127 | + }); |
| 6128 | + }); |
| 6129 | + |
| 6130 | + describe('#removeSelectPlacementsAttributePersistenceDeniedAttributes', () => { |
| 6131 | + it('should remove denylisted attributes case-insensitively', () => { |
| 6132 | + const attributes = { |
| 6133 | + confirmationRef: 'previous-order', |
| 6134 | + PaymentServiceProvider: 'test-provider', |
| 6135 | + cartItems: [{ sku: 'test-sku' }], |
| 6136 | + conversionType: 'purchase', |
| 6137 | + loyaltyTier: 'gold', |
| 6138 | + }; |
| 6139 | + |
| 6140 | + expect(removeSelectPlacementsAttributePersistenceDeniedAttributes(attributes)).toEqual({ |
| 6141 | + loyaltyTier: 'gold', |
| 6142 | + }); |
| 6143 | + expect(attributes).toEqual({ |
| 6144 | + confirmationRef: 'previous-order', |
| 6145 | + PaymentServiceProvider: 'test-provider', |
| 6146 | + cartItems: [{ sku: 'test-sku' }], |
| 6147 | + conversionType: 'purchase', |
| 6148 | + loyaltyTier: 'gold', |
| 6149 | + }); |
| 6150 | + }); |
| 6151 | + |
| 6152 | + it('should return an empty object for null or undefined attributes', () => { |
| 6153 | + expect(removeSelectPlacementsAttributePersistenceDeniedAttributes(null)).toEqual({}); |
| 6154 | + expect(removeSelectPlacementsAttributePersistenceDeniedAttributes(undefined)).toEqual({}); |
| 6155 | + }); |
| 6156 | + }); |
| 6157 | + |
6110 | 6158 | describe('#hashEventMessage', () => { |
6111 | 6159 | it('should hash event message using generateHash in the proper order', () => { |
6112 | 6160 | const eventName = 'Test Event'; |
|
0 commit comments