@@ -368,11 +368,36 @@ describe(createWrapper, () => {
368368 )
369369 } )
370370
371- it ( 'should allow integration if an integration has multiple categories, and user has multiple categories, but only consents to one ' , async ( ) => {
371+ it ( 'should allow integration if it has one category and user has consented to that category ' , async ( ) => {
372372 const mockCdnSettings = settingsBuilder
373373 . addActionDestinationSettings ( {
374374 creationName : 'mockIntegration' ,
375- ...createConsentSettings ( [ 'Bar' , 'Something else' ] ) ,
375+ ...createConsentSettings ( [ 'Foo' ] ) ,
376+ } )
377+ . build ( )
378+
379+ wrapTestAnalytics ( {
380+ shouldLoad : ( ) => ( { Foo : true } ) ,
381+ } )
382+ await analytics . load ( {
383+ ...DEFAULT_LOAD_SETTINGS ,
384+ cdnSettings : mockCdnSettings ,
385+ } )
386+ expect ( analyticsLoadSpy ) . toBeCalled ( )
387+ const { updatedCDNSettings } = getAnalyticsLoadLastCall ( )
388+ // remote plugins should be filtered based on consent settings
389+ expect ( updatedCDNSettings . remotePlugins ) . toContainEqual (
390+ mockCdnSettings . remotePlugins ?. find (
391+ ( p ) => p . creationName === 'mockIntegration'
392+ )
393+ )
394+ } )
395+
396+ it ( 'should allow integration if it has multiple categories and user consents to all of them.' , async ( ) => {
397+ const mockCdnSettings = settingsBuilder
398+ . addActionDestinationSettings ( {
399+ creationName : 'mockIntegration' ,
400+ ...createConsentSettings ( [ 'Foo' , 'Bar' ] ) ,
376401 } )
377402 . build ( )
378403
@@ -386,18 +411,18 @@ describe(createWrapper, () => {
386411 expect ( analyticsLoadSpy ) . toBeCalled ( )
387412 const { updatedCDNSettings } = getAnalyticsLoadLastCall ( )
388413 // remote plugins should be filtered based on consent settings
389- expect ( updatedCDNSettings . remotePlugins ) . toEqual (
390- mockCdnSettings . remotePlugins ?. filter (
414+ expect ( updatedCDNSettings . remotePlugins ) . toContainEqual (
415+ mockCdnSettings . remotePlugins ?. find (
391416 ( p ) => p . creationName === 'mockIntegration'
392417 )
393418 )
394419 } )
395420
396- it ( 'should allow integration if it has multiple consent categories but user has only consented to one category ' , async ( ) => {
421+ it ( 'should disable integration if it has multiple categories but user has only consented to one' , async ( ) => {
397422 const mockCdnSettings = settingsBuilder
398423 . addActionDestinationSettings ( {
399424 creationName : 'mockIntegration' ,
400- ...createConsentSettings ( [ 'Foo' , 'Something else ' ] ) ,
425+ ...createConsentSettings ( [ 'Foo' , 'Bar ' ] ) ,
401426 } )
402427 . build ( )
403428
@@ -410,8 +435,8 @@ describe(createWrapper, () => {
410435 } )
411436
412437 const { updatedCDNSettings } = getAnalyticsLoadLastCall ( )
413- expect ( updatedCDNSettings . remotePlugins ) . toEqual (
414- mockCdnSettings . remotePlugins ?. filter (
438+ expect ( updatedCDNSettings . remotePlugins ) . not . toContainEqual (
439+ mockCdnSettings . remotePlugins ?. find (
415440 ( p ) => p . creationName === 'mockIntegration'
416441 )
417442 )
0 commit comments