@@ -42,19 +42,17 @@ describe('Consent', function() {
4242 mParticle . _resetForTests ( MPConfig ) ;
4343 } ) ;
4444
45- it ( 'Should not create consent object without consented boolean' , done => {
45+ it ( 'Should not create consent object without consented boolean' , ( ) => {
4646 let consent = mParticle . Consent . createGDPRConsent ( null ) ;
4747 expect ( consent === null ) . to . be . ok ;
4848
4949 consent = mParticle . Consent . createGDPRConsent ( BadBoolean ) ;
5050
5151 consent = mParticle . Consent . createGDPRConsent ( BadStringBoolean ) ;
5252 expect ( consent === null ) . to . be . ok ;
53-
54- done ( ) ;
5553 } ) ;
5654
57- it ( 'Should create basic consent object with only consented boolean' , done => {
55+ it ( 'Should create basic consent object with only consented boolean' , ( ) => {
5856 let consent = mParticle . Consent . createGDPRConsent ( true ) ;
5957 expect ( consent ) . to . be . ok ;
6058
@@ -63,30 +61,26 @@ describe('Consent', function() {
6361 consent = mParticle . Consent . createGDPRConsent ( false ) ;
6462 expect ( consent ) . to . be . ok ;
6563 consent . Consented . should . equal ( false ) ;
66- done ( ) ;
6764 } ) ;
6865
69- it ( 'Should not create consent object with invalid document' , done => {
66+ it ( 'Should not create consent object with invalid document' , ( ) => {
7067 const badDocument = ( 123 as unknown ) as string ;
7168 const consent = mParticle
7269 . getInstance ( )
7370 . Consent . createGDPRConsent ( true , 123 , badDocument ) ;
7471 expect ( consent === null ) . to . be . ok ;
7572
76- done ( ) ;
7773 } ) ;
7874
79- it ( 'Should not create consent object with invalid location' , done => {
75+ it ( 'Should not create consent object with invalid location' , ( ) => {
8076 const badLocation = ( 123 as unknown ) as string ;
8177 const consent = mParticle
8278 . getInstance ( )
8379 . Consent . createGDPRConsent ( true , 123 , 'foo document' , badLocation ) ;
8480 expect ( consent === null ) . to . be . ok ;
85-
86- done ( ) ;
8781 } ) ;
8882
89- it ( 'Should not create consent object with invalid hardware id' , done => {
83+ it ( 'Should not create consent object with invalid hardware id' , ( ) => {
9084 const badHardwareId = ( 123 as unknown ) as string ;
9185 const consent = mParticle
9286 . getInstance ( )
@@ -98,18 +92,15 @@ describe('Consent', function() {
9892 badHardwareId
9993 ) ;
10094 expect ( consent === null ) . to . be . ok ;
101-
102- done ( ) ;
10395 } ) ;
10496
105- it ( 'Should set current timestamp if none given' , done => {
97+ it ( 'Should set current timestamp if none given' , ( ) => {
10698 const date = Date . now ( ) ;
10799 const consent = mParticle . Consent . createGDPRConsent ( true ) ;
108100 expect ( consent . Timestamp ) . to . be . greaterThanOrEqual ( date ) ;
109- done ( ) ;
110101 } ) ;
111102
112- it ( 'Should create complete object' , done => {
103+ it ( 'Should create complete object' , ( ) => {
113104 const consent = mParticle
114105 . getInstance ( )
115106 . Consent . createGDPRConsent (
@@ -125,18 +116,16 @@ describe('Consent', function() {
125116 consent . should . have . property ( 'ConsentDocument' , 'foo document' ) ;
126117 consent . should . have . property ( 'Location' , 'foo location' ) ;
127118 consent . should . have . property ( 'HardwareId' , 'foo hardware id' ) ;
128- done ( ) ;
129119 } ) ;
130120
131- it ( 'Should create basic ConsentState object' , done => {
121+ it ( 'Should create basic ConsentState object' , ( ) => {
132122 const consentState = mParticle
133123 . getInstance ( )
134124 . Consent . createConsentState ( ) ;
135125 expect ( consentState ) . to . be . ok ;
136- done ( ) ;
137126 } ) ;
138127
139- it ( 'Should add GDPR ConsentState object' , done => {
128+ it ( 'Should add GDPR ConsentState object' , ( ) => {
140129 const consentState = mParticle
141130 . getInstance ( )
142131 . Consent . createConsentState ( ) ;
@@ -170,11 +159,9 @@ describe('Consent', function() {
170159 'Consented' ,
171160 false
172161 ) ;
173-
174- done ( ) ;
175162 } ) ;
176163
177- it ( 'Should replace GDPR ConsentState object' , done => {
164+ it ( 'Should replace GDPR ConsentState object' , ( ) => {
178165 const consentState = mParticle
179166 . getInstance ( )
180167 . Consent . createConsentState ( ) ;
@@ -205,11 +192,9 @@ describe('Consent', function() {
205192 consentState . getGDPRConsentState ( ) . should . not . have . property ( 'foo' ) ;
206193 consentState . getGDPRConsentState ( ) . should . have . property ( 'bar' ) ;
207194 consentState . getGDPRConsentState ( ) . should . have . property ( 'baz' ) ;
208-
209- done ( ) ;
210195 } ) ;
211196
212- it ( 'should not be able to modify GDPR ConsentState object' , done => {
197+ it ( 'should not be able to modify GDPR ConsentState object' , ( ) => {
213198 const consentState = mParticle
214199 . getInstance ( )
215200 . Consent . createConsentState ( ) ;
@@ -230,11 +215,9 @@ describe('Consent', function() {
230215 delete consentState . getGDPRConsentState ( ) . foo ;
231216
232217 consentState . getGDPRConsentState ( ) . should . have . property ( 'foo' ) ;
233-
234- done ( ) ;
235218 } ) ;
236219
237- it ( 'Should copy GDPR ConsentState object' , done => {
220+ it ( 'Should copy GDPR ConsentState object' , ( ) => {
238221 const consentState = mParticle
239222 . getInstance ( )
240223 . Consent . createConsentState ( ) ;
@@ -286,11 +269,9 @@ describe('Consent', function() {
286269 'Consented' ,
287270 false
288271 ) ;
289-
290- done ( ) ;
291272 } ) ;
292273
293- it ( 'Should remove GDPR ConsentState object' , done => {
274+ it ( 'Should remove GDPR ConsentState object' , ( ) => {
294275 const consentState = mParticle
295276 . getInstance ( )
296277 . Consent . createConsentState ( ) ;
@@ -313,10 +294,9 @@ describe('Consent', function() {
313294
314295 consentState . getGDPRConsentState ( ) . should . not . have . property ( 'bar' ) ;
315296 consentState . getGDPRConsentState ( ) . should . have . property ( 'foo' ) ;
316- done ( ) ;
317297 } ) ;
318298
319- it ( 'Should normalize GDPR consent purposes on add' , done => {
299+ it ( 'Should normalize GDPR consent purposes on add' , ( ) => {
320300 const consentState = mParticle
321301 . getInstance ( )
322302 . Consent . createConsentState ( ) ;
@@ -351,11 +331,9 @@ describe('Consent', function() {
351331 expect ( gdprConsentState . bar ) . to . have . property ( 'Timestamp' , 2 ) ;
352332 expect ( gdprConsentState ) . to . not . have . property ( 'BAZ ' ) ;
353333 expect ( gdprConsentState . baz ) . to . have . property ( 'Timestamp' , 3 ) ;
354-
355- done ( ) ;
356334 } ) ;
357335
358- it ( 'Should normalize GDPR consent purposes on remove' , done => {
336+ it ( 'Should normalize GDPR consent purposes on remove' , ( ) => {
359337 const consentState = mParticle
360338 . getInstance ( )
361339 . Consent . createConsentState ( ) ;
@@ -391,11 +369,9 @@ describe('Consent', function() {
391369 expect ( gdprConsentStateUpdate ) . to . not . have . property ( 'foo' ) ;
392370 expect ( gdprConsentStateUpdate ) . to . not . have . property ( 'bar' ) ;
393371 expect ( gdprConsentStateUpdate ) . to . not . have . property ( 'baz' ) ;
394-
395- done ( ) ;
396372 } ) ;
397373
398- it ( 'Should not set junk GDPR object' , done => {
374+ it ( 'Should not set junk GDPR object' , ( ) => {
399375 const consentState = mParticle
400376 . getInstance ( )
401377 . Consent . createConsentState ( ) ;
@@ -419,11 +395,9 @@ describe('Consent', function() {
419395 expect ( consentState . getGDPRConsentState ( ) ) . to . not . have . property (
420396 ( 10 as unknown ) as string
421397 ) ;
422-
423- done ( ) ;
424398 } ) ;
425399
426- it ( 'Should toJson/fromJson complete Consent State object' , done => {
400+ it ( 'Should toJson/fromJson complete Consent State object' , ( ) => {
427401 const consent1 = mParticle
428402 . getInstance ( )
429403 . Consent . createGDPRConsent (
@@ -479,23 +453,19 @@ describe('Consent', function() {
479453 consentCopy2 . should . have . property ( 'ConsentDocument' , 'foo document 2' ) ;
480454 consentCopy2 . should . have . property ( 'Location' , 'foo location 2' ) ;
481455 consentCopy2 . should . have . property ( 'HardwareId' , 'foo hardware id 2' ) ;
482-
483- done ( ) ;
484456 } ) ;
485457
486- it ( 'Should not create a CCPA consent object without consented boolean' , done => {
458+ it ( 'Should not create a CCPA consent object without consented boolean' , ( ) => {
487459 let consent = mParticle . Consent . createCCPAConsent ( null ) ;
488460 expect ( consent === null ) . to . be . ok ;
489461
490462 consent = mParticle . Consent . createCCPAConsent ( BadBoolean ) ;
491463
492464 consent = mParticle . Consent . createCCPAConsent ( BadStringBoolean ) ;
493465 expect ( consent === null ) . to . be . ok ;
494-
495- done ( ) ;
496466 } ) ;
497467
498- it ( 'Should create basic consent object with only consented boolean' , done => {
468+ it ( 'Should create basic consent object with only consented boolean' , ( ) => {
499469 let consent = mParticle . Consent . createCCPAConsent ( true ) ;
500470 expect ( consent ) . to . be . ok ;
501471
@@ -504,30 +474,25 @@ describe('Consent', function() {
504474 consent = mParticle . Consent . createCCPAConsent ( false ) ;
505475 expect ( consent ) . to . be . ok ;
506476 consent . Consented . should . equal ( false ) ;
507- done ( ) ;
508477 } ) ;
509478
510- it ( 'Should not create consent object with invalid document' , done => {
479+ it ( 'Should not create consent object with invalid document' , ( ) => {
511480 const badDocument = ( 123 as unknown ) as string ;
512481 const consent = mParticle
513482 . getInstance ( )
514483 . Consent . createCCPAConsent ( true , 123 , badDocument ) ;
515484 expect ( consent === null ) . to . be . ok ;
516-
517- done ( ) ;
518485 } ) ;
519486
520- it ( 'Should not create consent object with invalid location' , done => {
487+ it ( 'Should not create consent object with invalid location' , ( ) => {
521488 const badLocation = ( 123 as unknown ) as string ;
522489 const consent = mParticle
523490 . getInstance ( )
524491 . Consent . createCCPAConsent ( true , 123 , 'foo document' , badLocation ) ;
525492 expect ( consent === null ) . to . be . ok ;
526-
527- done ( ) ;
528493 } ) ;
529494
530- it ( 'Should not create consent object with invalid hardware id' , done => {
495+ it ( 'Should not create consent object with invalid hardware id' , ( ) => {
531496 const badHardwareId = ( 123 as unknown ) as string ;
532497 const consent = mParticle
533498 . getInstance ( )
@@ -539,18 +504,15 @@ describe('Consent', function() {
539504 badHardwareId
540505 ) ;
541506 expect ( consent === null ) . to . be . ok ;
542-
543- done ( ) ;
544507 } ) ;
545508
546- it ( 'Should set current timestamp if none given' , done => {
509+ it ( 'Should set current timestamp if none given' , ( ) => {
547510 const date = Date . now ( ) ;
548511 const consent = mParticle . Consent . createCCPAConsent ( true ) ;
549512 expect ( consent . Timestamp ) . to . be . greaterThanOrEqual ( date ) ;
550- done ( ) ;
551513 } ) ;
552514
553- it ( 'Should create complete CCPA consent object' , done => {
515+ it ( 'Should create complete CCPA consent object' , ( ) => {
554516 const consent = mParticle
555517 . getInstance ( )
556518 . Consent . createCCPAConsent (
@@ -566,11 +528,9 @@ describe('Consent', function() {
566528 consent . should . have . property ( 'ConsentDocument' , 'foo document' ) ;
567529 consent . should . have . property ( 'Location' , 'foo location' ) ;
568530 consent . should . have . property ( 'HardwareId' , 'foo hardware id' ) ;
569-
570- done ( ) ;
571531 } ) ;
572532
573- it ( 'Should set CCPA ConsentState object' , done => {
533+ it ( 'Should set CCPA ConsentState object' , ( ) => {
574534 const consentState = mParticle
575535 . getInstance ( )
576536 . Consent . createConsentState ( ) ;
@@ -593,11 +553,9 @@ describe('Consent', function() {
593553 expect ( consentState . getCCPAConsentState ( ) ) . to . have . property (
594554 'Timestamp'
595555 ) ;
596-
597- done ( ) ;
598556 } ) ;
599557
600- it ( 'Should remove CCPA ConsentState object' , done => {
558+ it ( 'Should remove CCPA ConsentState object' , ( ) => {
601559 const consentState = mParticle
602560 . getInstance ( )
603561 . Consent . createConsentState ( ) ;
@@ -623,11 +581,9 @@ describe('Consent', function() {
623581
624582 consentState . removeCCPAConsentState ( ) ;
625583 expect ( consentState . getCCPAConsentState ( ) === undefined ) . to . equal ( true ) ;
626-
627- done ( ) ;
628584 } ) ;
629585
630- it ( 'should have CCPA in payload' , done => {
586+ it ( 'should have CCPA in payload' , async ( ) => {
631587 const consentState = mParticle . Consent . createConsentState ( ) ;
632588 const timestamp = new Date ( ) . getTime ( ) ;
633589 const ccpaConsent = mParticle . Consent . createCCPAConsent (
@@ -639,8 +595,7 @@ describe('Consent', function() {
639595 ) ;
640596 consentState . setCCPAConsentState ( ccpaConsent ) ;
641597
642- waitForCondition ( hasIdentifyReturned )
643- . then ( ( ) => {
598+ await waitForCondition ( hasIdentifyReturned ) ;
644599 const user = mParticle . Identity . getCurrentUser ( ) ;
645600 user . setConsentState ( consentState ) ;
646601
@@ -655,12 +610,9 @@ describe('Consent', function() {
655610 testEvent . consent_state . ccpa . data_sale_opt_out . should . have . property ( 'document' , 'consentDoc' ) ;
656611 testEvent . consent_state . ccpa . data_sale_opt_out . should . have . property ( 'location' , 'location' ) ;
657612 testEvent . consent_state . ccpa . data_sale_opt_out . should . have . property ( 'hardware_id' , 'hardware' ) ;
658-
659- done ( ) ;
660- } )
661613 } ) ;
662614
663- it ( 'should have CCPA and GDPR in payload' , done => {
615+ it ( 'should have CCPA and GDPR in payload' , async ( ) => {
664616 const consentState = mParticle . Consent . createConsentState ( ) ;
665617 const timestamp = new Date ( ) . getTime ( ) ;
666618 const ccpaConsent = mParticle . Consent . createCCPAConsent (
@@ -679,8 +631,7 @@ describe('Consent', function() {
679631 ) ;
680632 consentState . setCCPAConsentState ( ccpaConsent ) ;
681633 consentState . addGDPRConsentState ( 'test purpose' , gdprConsent ) ;
682- waitForCondition ( hasIdentifyReturned )
683- . then ( ( ) => {
634+ await waitForCondition ( hasIdentifyReturned ) ;
684635
685636 const user = mParticle . Identity . getCurrentUser ( ) ;
686637 user . setConsentState ( consentState ) ;
@@ -706,13 +657,10 @@ describe('Consent', function() {
706657 testEvent . consent_state . gdpr [ 'test purpose' ] . should . have . property ( 'document' , 'consentDoc' ) ;
707658 testEvent . consent_state . gdpr [ 'test purpose' ] . should . have . property ( 'location' , 'location' ) ;
708659 testEvent . consent_state . gdpr [ 'test purpose' ] . should . have . property ( 'hardware_id' , 'hardware' ) ;
709-
710- done ( ) ;
711- } )
712660 } ) ;
713661
714662 // TODO: Deprecate in next major version
715- it ( 'Should log deprecated message when using removeCCPAState' , done => {
663+ it ( 'Should log deprecated message when using removeCCPAState' , ( ) => {
716664 const bond = sinon . spy ( mParticle . getInstance ( ) . Logger , 'warning' ) ;
717665 const consentState = mParticle
718666 . getInstance ( )
@@ -745,7 +693,5 @@ describe('Consent', function() {
745693 bond . getCalls ( ) [ 0 ] . args [ 0 ] . should . eql (
746694 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead'
747695 ) ;
748-
749- done ( ) ;
750696 } ) ;
751697} ) ;
0 commit comments