@@ -15,6 +15,7 @@ import {
1515} from './utils' ;
1616import config from './config' ;
1717
18+ let vendorList = { vendors : [ { id : 1 } , { id : 3 } , { id : 4 } ] } ;
1819
1920describe ( 'utils' , ( ) => {
2021 describe ( 'checkReprompt' , ( ) => {
@@ -37,7 +38,7 @@ describe('utils', () => {
3738 "1" : false ,
3839 }
3940 } ;
40- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
41+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
4142 } ) ;
4243
4344 it ( 'returns true if atleast one cookie is not set' , ( ) => {
@@ -58,7 +59,7 @@ describe('utils', () => {
5859 "1" : false ,
5960 }
6061 } ;
61- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
62+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
6263 } ) ;
6364
6465 it ( 'returns false if for new cookies' , ( ) => {
@@ -80,7 +81,7 @@ describe('utils', () => {
8081 "1" : false ,
8182 }
8283 } ;
83- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( false ) ;
84+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( false ) ;
8485 } ) ;
8586
8687 it ( 'handles reprompt options' , ( ) => {
@@ -92,6 +93,9 @@ describe('utils', () => {
9293 } ,
9394 "vendorConsents" : {
9495 "1" : true ,
96+ "2" : false ,
97+ "3" : true ,
98+ "4" : true ,
9599 }
96100 } ;
97101 const publisherConsent = {
@@ -104,29 +108,29 @@ describe('utils', () => {
104108 }
105109 } ;
106110
107- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( false ) ;
111+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( false ) ;
108112
109113 vendorConsent . lastUpdated = Date . now ( ) - 100 * day ;
110- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( false ) ;
114+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( false ) ;
111115
112116 vendorConsent . lastUpdated = Date . now ( ) - 361 * day ;
113- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
117+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
114118 vendorConsent . lastUpdated = Date . now ( ) - 500 * day ;
115- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
119+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
116120
117121 vendorConsent . purposeConsents [ '1' ] = false ;
118122 vendorConsent . lastUpdated = Date . now ( ) - 29 * day ;
119- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( false ) ;
123+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( false ) ;
120124 vendorConsent . lastUpdated = Date . now ( ) - 31 * day ;
121- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
125+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
122126
123127 vendorConsent . vendorConsents [ '1' ] = false ;
124128 publisherConsent . customPurposes [ '1' ] = false ;
125129 publisherConsent . standardPurposes [ '1' ] = false ;
126130 vendorConsent . lastUpdated = Date . now ( ) - 29 * day ;
127- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( false ) ;
131+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( false ) ;
128132 vendorConsent . lastUpdated = Date . now ( ) - 31 * day ;
129- expect ( checkReprompt ( repromptOptions , vendorConsent , publisherConsent ) ) . eq ( true ) ;
133+ expect ( checkReprompt ( repromptOptions , vendorList , vendorConsent , publisherConsent ) ) . eq ( true ) ;
130134 } ) ;
131135 } ) ;
132136
@@ -227,6 +231,16 @@ describe('utils', () => {
227231 describe ( 'getConsentsCount' , ( ) => {
228232 let consentObject ;
229233 beforeEach ( ( ) => {
234+ vendorList = {
235+ vendors : [
236+ { id : 1 } ,
237+ { id : 2 } ,
238+ { id : 3 } ,
239+ { id : 4 } ,
240+ { id : 5 } ,
241+ { id : 6 }
242+ ]
243+ } ;
230244 consentObject = {
231245 "cookieVersion" : 1 ,
232246 "cmpId" : 1 ,
@@ -260,19 +274,19 @@ describe('utils', () => {
260274 } ) ;
261275
262276 it ( 'returns total amount of required consents' , ( ) => {
263- expect ( getConsentsCount ( consentObject ) . total ) . eq ( 16 ) ;
277+ expect ( getConsentsCount ( consentObject , vendorList ) . total ) . eq ( 16 ) ;
264278 consentObject . customPurposes [ '4' ] = true ;
265- expect ( getConsentsCount ( consentObject ) . total ) . eq ( 17 ) ;
279+ expect ( getConsentsCount ( consentObject , vendorList ) . total ) . eq ( 17 ) ;
266280 delete consentObject . vendorConsents ;
267- expect ( getConsentsCount ( consentObject ) . total ) . eq ( 11 ) ;
281+ expect ( getConsentsCount ( consentObject , vendorList ) . total ) . eq ( 11 ) ;
268282 } ) ;
269283
270284 it ( 'returns amount of required granted consents' , ( ) => {
271- expect ( getConsentsCount ( consentObject ) . consented ) . eq ( 12 ) ;
285+ expect ( getConsentsCount ( consentObject , vendorList ) . consented ) . eq ( 12 ) ;
272286 consentObject . customPurposes [ '4' ] = true ;
273- expect ( getConsentsCount ( consentObject ) . consented ) . eq ( 13 ) ;
287+ expect ( getConsentsCount ( consentObject , vendorList ) . consented ) . eq ( 13 ) ;
274288 delete consentObject . vendorConsents ;
275- expect ( getConsentsCount ( consentObject ) . consented ) . eq ( 9 ) ;
289+ expect ( getConsentsCount ( consentObject , vendorList ) . consented ) . eq ( 9 ) ;
276290 } ) ;
277291 } ) ;
278292
0 commit comments