@@ -2859,8 +2859,9 @@ describe('AmplitudeClient', function () {
28592859
28602860 it ( 'should not set eventUploadThreshold with invalid eventUploadThreshold value' , function ( ) {
28612861 amplitude . init ( apiKey ) ;
2862+ let previousEventUploadThreshold = amplitude . options . eventUploadThreshold ;
28622863 amplitude . setEventUploadThreshold ( 'invalid eventUploadThreshold' ) ;
2863- assert . equal ( amplitude . options . eventUploadThreshold , 30 ) ;
2864+ assert . equal ( amplitude . options . eventUploadThreshold , previousEventUploadThreshold ) ;
28642865 } ) ;
28652866
28662867 it ( 'should set eventUploadThreshold' , function ( ) {
@@ -2953,9 +2954,9 @@ describe('AmplitudeClient', function () {
29532954
29542955 it ( 'should not set optOut with invalid input' , function ( ) {
29552956 amplitude . init ( apiKey ) ;
2956- let optOut = 'invalid sessionTimeOut' ;
2957- amplitude . setOptOut ( optOut ) ;
2958- assert . equal ( amplitude . options . optOut , false ) ;
2957+ let previousOptOut = amplitude . options . optOut ;
2958+ amplitude . setOptOut ( 'invalid sessionTimeOut' ) ;
2959+ assert . equal ( amplitude . options . optOut , previousOptOut ) ;
29592960 } ) ;
29602961
29612962 it ( 'should set optOut' , function ( ) {
@@ -4237,7 +4238,7 @@ describe('AmplitudeClient', function () {
42374238 reset ( ) ;
42384239 } ) ;
42394240
4240- it ( 'EU serverZone should not set apiEndpoint to EU because of invaid useDynamicConfig value' , function ( ) {
4241+ it ( 'EU serverZone should not set apiEndpoint to EU because of invalid useDynamicConfig value' , function ( ) {
42414242 assert . equal ( amplitude . options . apiEndpoint , constants . EVENT_LOG_URL ) ;
42424243 amplitude . init ( apiKey , null , {
42434244 serverZone : AmplitudeServerZone . EU ,
@@ -4282,7 +4283,7 @@ describe('AmplitudeClient', function () {
42824283 it ( 'should set serverUrl with valid serverUrl input' , function ( ) {
42834284 assert . equal ( amplitude . options . apiEndpoint , constants . EVENT_LOG_URL ) ;
42844285 amplitude . init ( apiKey ) ;
4285- amplitude . setServerUrl ( 'api.eu.amplitude.com' ) ;
4286+ amplitude . setServerUrl ( constants . EVENT_LOG_EU_URL ) ;
42864287 assert . equal ( amplitude . options . apiEndpoint , constants . EVENT_LOG_EU_URL ) ;
42874288 } ) ;
42884289 } ) ;
@@ -4293,40 +4294,33 @@ describe('AmplitudeClient', function () {
42934294 } ) ;
42944295
42954296 it ( 'should not set serverZone with invalid serverZone value' , function ( ) {
4296- assert . equal ( amplitude . options . serverZone , 'US' ) ;
42974297 amplitude . init ( apiKey ) ;
4298+ let previousServerZone = amplitude . options . serverZone ;
42984299 amplitude . setServerZone ( 'invalid serverZone' ) ;
4299- assert . equal ( amplitude . options . serverZone , 'US' ) ;
4300+ assert . equal ( amplitude . options . serverZone , previousServerZone ) ;
43004301 } ) ;
43014302
43024303 it ( 'should not set serverZone with invalid serverZoneBasedApi value' , function ( ) {
4303- assert . equal ( amplitude . options . serverZone , 'US' ) ;
43044304 amplitude . init ( apiKey ) ;
4305- amplitude . setServerZone ( 'EU' , 'invalid serverZoneBasedApi' ) ;
4306- assert . equal ( amplitude . options . serverZone , 'US' ) ;
4305+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . US ) ;
4306+ amplitude . setServerZone ( AmplitudeServerZone . EU , 'invalid serverZoneBasedApi' ) ;
4307+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . US ) ;
43074308 } ) ;
43084309
43094310 it ( 'should set serverZone to EU' , function ( ) {
4310- assert . equal ( amplitude . options . serverZone , 'US' ) ;
4311- amplitude . init ( apiKey ) ;
4312- amplitude . setServerZone ( 'EU' ) ;
4313- assert . equal ( amplitude . options . serverZone , 'EU' ) ;
4314- } ) ;
4315-
4316- it ( 'should set serverZont to EU and serverUrl to EVENT_LOG_EU_URL with serverZoneBasedApi is true' , function ( ) {
4317- assert . equal ( amplitude . options . serverZone , 'US' ) ;
43184311 amplitude . init ( apiKey ) ;
4319- amplitude . setServerZone ( 'EU' , true ) ;
4320- assert . equal ( amplitude . options . serverZone , 'EU' ) ;
4321- assert . equal ( amplitude . options . apiEndpoint , 'api.eu.amplitude.com' ) ;
4312+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . US ) ;
4313+ amplitude . setServerZone ( AmplitudeServerZone . EU ) ;
4314+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . EU ) ;
4315+ assert . equal ( amplitude . options . apiEndpoint , constants . EVENT_LOG_EU_URL ) ;
43224316 } ) ;
43234317
4324- it ( 'should set serverZont to EU and keep the default serverUrl with serverZoneBasedApi is false' , function ( ) {
4325- assert . equal ( amplitude . options . serverZone , 'US' ) ;
4318+ it ( 'should set serverZone to EU and keep the default serverUrl with serverZoneBasedApi is false' , function ( ) {
43264319 amplitude . init ( apiKey ) ;
4327- amplitude . setServerZone ( 'EU' , false ) ;
4328- assert . equal ( amplitude . options . serverZone , 'EU' ) ;
4329- assert . equal ( amplitude . options . apiEndpoint , 'api.amplitude.com' ) ;
4320+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . US ) ;
4321+ amplitude . setServerZone ( AmplitudeServerZone . EU , false ) ;
4322+ assert . equal ( amplitude . options . serverZone , AmplitudeServerZone . EU ) ;
4323+ assert . equal ( amplitude . options . apiEndpoint , constants . EVENT_LOG_URL ) ;
43304324 } ) ;
43314325 } ) ;
43324326
@@ -4338,7 +4332,7 @@ describe('AmplitudeClient', function () {
43384332 it ( 'should get userId' , function ( ) {
43394333 amplitude . init ( apiKey , userId ) ;
43404334 let currentUserId = amplitude . getUserId ( ) ;
4341- assert . equal ( amplitude . options . userId , currentUserId ) ;
4335+ assert . equal ( currentUserId , userId ) ;
43424336 } ) ;
43434337
43444338 it ( 'should get userId null' , function ( ) {
@@ -4371,9 +4365,10 @@ describe('AmplitudeClient', function () {
43714365
43724366 it ( 'should not set sessionTimeout with invalid input' , function ( ) {
43734367 amplitude . init ( apiKey ) ;
4368+ let previousSessionTimeOut = amplitude . options . sessionTimeout ;
43744369 let newSessionTimeOut = 'invalid sessionTimeOut' ;
43754370 amplitude . setMinTimeBetweenSessionsMillis ( newSessionTimeOut ) ;
4376- assert . equal ( amplitude . options . sessionTimeout , 30 * 60 * 1000 ) ;
4371+ assert . equal ( amplitude . options . sessionTimeout , previousSessionTimeOut ) ;
43774372 } ) ;
43784373
43794374 it ( 'should set sessionTimeout' , function ( ) {
@@ -4416,13 +4411,15 @@ describe('AmplitudeClient', function () {
44164411 clock . tick ( sessionId ) ;
44174412 amplitude . init ( apiKey ) ;
44184413 assert . equal ( amplitude . getSessionId ( ) , startTime ) ;
4414+ assert . equal ( amplitude . options . userId , null ) ;
44194415
44204416 amplitude . setUserId ( 'test user' , 'invalid startNewSession' ) ;
44214417 assert . notEqual ( amplitude . getSessionId ( ) , new Date ( ) . getTime ( ) ) ;
44224418 assert . notEqual ( amplitude . options . userId , 'test user' ) ;
4419+ assert . equal ( amplitude . options . userId , null ) ;
44234420 } ) ;
44244421
4425- it ( 'should renew the session id with current timestemp' , function ( ) {
4422+ it ( 'should set user id and renew the session id with current timestemp' , function ( ) {
44264423 var amplitude = new AmplitudeClient ( ) ;
44274424 // set up initial session
44284425 var sessionId = 1000 ;
0 commit comments