@@ -2739,23 +2739,54 @@ describe('AmplitudeClient', function () {
2739
2739
} ) ;
2740
2740
} ) ;
2741
2741
2742
- it ( 'should not create any cookies if disabledCookies = true' , function ( ) {
2742
+ it ( 'should not use any cookies with simple host if disabledCookies = true' , function ( ) {
2743
2743
deleteAllCookies ( ) ;
2744
2744
clock . tick ( 20 ) ;
2745
2745
2746
2746
var cookieArray = getAllCookies ( ) ;
2747
2747
assert . equal ( cookieArray . length , 0 ) ;
2748
2748
2749
2749
var deviceId = 'test_device_id' ;
2750
- var amplitude2 = new AmplitudeClient ( ) ;
2750
+ var amplitude = new AmplitudeClient ( ) ;
2751
2751
2752
- amplitude2 . init ( apiKey , null , {
2752
+ amplitude . init ( apiKey , null , {
2753
+ deviceId : deviceId ,
2754
+ disableCookies : true ,
2755
+ } ) ;
2756
+
2757
+ cookieArray = getAllCookies ( ) ;
2758
+ assert . equal ( cookieArray . length , 0 ) ;
2759
+ } ) ;
2760
+
2761
+ it ( 'should not use any cookies with multiple domains in host if disabledCookies = true' , function ( ) {
2762
+ const stubbedGetLocation = sinon . stub ( utils , 'getLocation' ) . returns ( { href : 'https://abc.def.xyz/test' } ) ;
2763
+ const spiedSet = sinon . spy ( baseCookie , 'set' ) ;
2764
+ const spiedGet = sinon . spy ( baseCookie , 'get' ) ;
2765
+ deleteAllCookies ( ) ;
2766
+ clock . tick ( 20 ) ;
2767
+
2768
+ var cookieArray = getAllCookies ( ) ;
2769
+ assert . equal ( cookieArray . length , 0 ) ;
2770
+
2771
+ var deviceId = 'test_device_id' ;
2772
+ var amplitude = new AmplitudeClient ( ) ;
2773
+
2774
+ amplitude . init ( apiKey , null , {
2753
2775
deviceId : deviceId ,
2754
2776
disableCookies : true ,
2755
2777
} ) ;
2756
2778
2757
2779
cookieArray = getAllCookies ( ) ;
2758
2780
assert . equal ( cookieArray . length , 0 ) ;
2781
+
2782
+ // spied cookie operations should not be fired
2783
+ assert . equal ( spiedSet . called , false ) ;
2784
+ assert . equal ( spiedGet . called , false ) ;
2785
+
2786
+ // restore stub, spy
2787
+ stubbedGetLocation . restore ( ) ;
2788
+ spiedSet . restore ( ) ;
2789
+ spiedGet . restore ( ) ;
2759
2790
} ) ;
2760
2791
2761
2792
it ( 'should create cookies if disabledCookies = false' , function ( ) {
@@ -2766,9 +2797,9 @@ describe('AmplitudeClient', function () {
2766
2797
assert . equal ( cookieArray . length , 0 ) ;
2767
2798
2768
2799
var deviceId = 'test_device_id' ;
2769
- var amplitude2 = new AmplitudeClient ( ) ;
2800
+ var amplitude = new AmplitudeClient ( ) ;
2770
2801
2771
- amplitude2 . init ( apiKey , null , {
2802
+ amplitude . init ( apiKey , null , {
2772
2803
deviceId : deviceId ,
2773
2804
disableCookies : false ,
2774
2805
} ) ;
0 commit comments