File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,16 @@ describe('AdriverIdSystem', function () {
66
66
let request = server . requests [ 0 ] ;
67
67
request . respond ( 200 , { 'Content-Type' : 'application/json' } , JSON . stringify ( { adrcid : response . adrcid } ) ) ;
68
68
69
- let now = new Date ( ) ;
70
- now . setTime ( now . getTime ( ) + 86400 * 1825 * 1000 ) ;
69
+ let expectedExpiration = new Date ( ) ;
70
+ expectedExpiration . setTime ( expectedExpiration . getTime ( ) + 86400 * 1825 * 1000 ) ;
71
71
const minimalDate = new Date ( 0 ) . toString ( ) ;
72
72
73
+ function dateStringFor ( date , maxDeltaMs = 2000 ) {
74
+ return sinon . match ( ( val ) => Math . abs ( date . getTime ( ) - new Date ( val ) . getTime ( ) ) <= maxDeltaMs )
75
+ }
76
+
73
77
if ( response . adrcid ) {
74
- expect ( setCookieStub . calledWith ( 'adrcid' , response . adrcid , now . toUTCString ( ) ) ) . to . be . true ;
78
+ expect ( setCookieStub . calledWith ( 'adrcid' , response . adrcid , dateStringFor ( expectedExpiration ) ) ) . to . be . true ;
75
79
expect ( setLocalStorageStub . calledWith ( 'adrcid' , response . adrcid ) ) . to . be . true ;
76
80
} else {
77
81
expect ( setCookieStub . calledWith ( 'adrcid' , '' , minimalDate ) ) . to . be . false ;
You can’t perform that action at this time.
0 commit comments