@@ -1263,14 +1263,43 @@ describe('Amplitude', function() {
12631263 assert . lengthOf ( event . event_properties [ 'key' ] , 1024 ) ;
12641264 } ) ;
12651265
1266- it ( 'should truncate long user property strings' , function ( ) {
1266+ it ( 'should truncate long user property strings' , function ( ) {
12671267 var longString = new Array ( 2000 ) . join ( 'a' ) ;
12681268 amplitude . identify ( new Identify ( ) . set ( 'key' , longString ) ) ;
12691269 var event = JSON . parse ( querystring . parse ( server . requests [ 0 ] . requestBody ) . e ) [ 0 ] ;
12701270
12711271 assert . isTrue ( '$set' in event . user_properties ) ;
12721272 assert . lengthOf ( event . user_properties [ '$set' ] [ 'key' ] , 1024 ) ;
12731273 } ) ;
1274+
1275+ it ( 'should increment the counters in local storage if cookies disabled' , function ( ) {
1276+ localStorage . clear ( ) ;
1277+ var deviceId = 'test_device_id' ;
1278+ var amplitude2 = new Amplitude ( ) ;
1279+
1280+ sinon . stub ( CookieStorage . prototype , '_cookiesEnabled' ) . returns ( false ) ;
1281+ amplitude2 . init ( apiKey , null , { deviceId : deviceId , batchEvents : true , eventUploadThreshold : 5 } ) ;
1282+ CookieStorage . prototype . _cookiesEnabled . restore ( ) ;
1283+
1284+ amplitude2 . logEvent ( 'test' ) ;
1285+ clock . tick ( 10 ) ; // starts the session
1286+ amplitude2 . logEvent ( 'test2' ) ;
1287+ clock . tick ( 20 ) ;
1288+ amplitude2 . setUserProperties ( { 'key' :'value' } ) ; // identify event at time 30
1289+
1290+ var cookieData = JSON . parse ( localStorage . getItem ( 'amp_cookiestore_amplitude_id' ) ) ;
1291+ console . log ( cookieData ) ;
1292+ assert . deepEqual ( cookieData , {
1293+ 'deviceId' : deviceId ,
1294+ 'userId' : null ,
1295+ 'optOut' : false ,
1296+ 'sessionId' : 10 ,
1297+ 'lastEventTime' : 30 ,
1298+ 'eventId' : 2 ,
1299+ 'identifyId' : 1 ,
1300+ 'sequenceNumber' : 3
1301+ } ) ;
1302+ } ) ;
12741303 } ) ;
12751304
12761305 describe ( 'optOut' , function ( ) {
0 commit comments