@@ -7,6 +7,7 @@ import KitBlocker from '../../src/kitBlocking';
77import Types from '../../src/types' ;
88import { DataPlanVersion } from '@mparticle/data-planning-models' ;
99import fetchMock from 'fetch-mock/esm/client' ;
10+ import { expect } from 'chai'
1011const { findBatch, waitForCondition, fetchMockSuccess, hasIdentifyReturned } = Utils ;
1112
1213let forwarderDefaultConfiguration = Utils . forwarderDefaultConfiguration ,
@@ -616,6 +617,26 @@ describe('kit blocking', () => {
616617 } )
617618 } ) ;
618619
620+ it ( 'integration test - should not throw an error when unplanned user attributes are allowed and block.ua = true' , function ( done ) {
621+ window . mParticle . config . kitConfigs . push ( forwarderDefaultConfiguration ( 'MockForwarder' ) ) ;
622+ window . mParticle . init ( apiKey , window . mParticle . config ) ;
623+
624+ // save old data points for reset later
625+ const oldDataPoints = dataPlan . dtpn . vers . version_document . data_points ;
626+ // when "Allow unplanned user attributes" is enabled, the data points returned is an empty array
627+ dataPlan . dtpn . vers . version_document . data_points = [ ] ;
628+ let kitBlocker = new KitBlocker ( kitBlockerDataPlan , window . mParticle . getInstance ( ) ) ;
629+
630+ expect ( ( ) => { kitBlocker . isAttributeKeyBlocked ( 'unplannedAttr' ) } ) . to . not . throw ( TypeError , / C a n n o t r e a d p r o p e r t i e s o f u n d e f i n e d \( r e a d i n g ' u n p l a n n e d A t t r ' \) / )
631+ // "Allow unplanned user attributes" is prioritized when blocking unplanned attributes is also enabled, hence the expected value is false
632+ expect ( kitBlocker . isAttributeKeyBlocked ( 'unplannedAttr' ) ) . to . equal ( false )
633+ // reset data points
634+ dataPlan . dtpn . vers . version_document . data_points = oldDataPoints ;
635+
636+ done ( ) ;
637+
638+ } ) ;
639+
619640 it ( 'integration test - should allow an unplanned attribute to be set on forwarder if additionalProperties = true and blok.ua = true' , function ( done ) {
620641 let userAttributeDataPoint = dataPlan . dtpn . vers . version_document . data_points . find ( dataPoint => {
621642 return dataPoint . match . type === 'user_attributes'
0 commit comments