@@ -150,13 +150,7 @@ describe('MoEngage', function() {
150150 'The anonymous ID should be different after an identify call'
151151 ) ;
152152 }
153- analytics . called ( moengage . _client . destroy_session ) ;
154153 analytics . called ( moengage . _client . add_unique_user_id , 'night king' ) ;
155- if ( moengage . initializedAnonymousId !== nightKingAnonId ) {
156- throw new Error (
157- 'MoEngange anonymous ID should be equal after an identify call'
158- ) ;
159- }
160154 } ) ;
161155
162156 it ( 'should not call destroy session if identify is called for a existing user' , function ( ) {
@@ -197,15 +191,6 @@ describe('MoEngage', function() {
197191 // Logout
198192 analytics . reset ( ) ;
199193 analytics . track ( 'The Song' , properties ) ;
200- if (
201- moengage . initializedAnonymousId !== analytics . user ( ) . anonymousId ( )
202- ) {
203- throw new Error (
204- 'MoEngange anonymous ID should be equal after an identify call'
205- ) ;
206- }
207- 1 ;
208- analytics . called ( moengage . _client . destroy_session ) ;
209194 } ) ;
210195
211196 it ( 'should not call destroy session if track is called for a existing user' , function ( ) {
@@ -223,16 +208,27 @@ describe('MoEngage', function() {
223208 } ) ;
224209 } ) ;
225210
226- describe ( '#reset ' , function ( ) {
211+ describe ( '#alias ' , function ( ) {
227212 beforeEach ( function ( ) {
228- analytics . stub ( moengage . _client , 'destroy_session ' ) ;
213+ analytics . stub ( moengage . _client , 'update_unique_user_id ' ) ;
229214 } ) ;
230-
231- it ( 'should destroy session upon reset' , function ( ) {
232- analytics . identify ( 'justin' ) ;
233- moengage . reset ( ) ;
234- analytics . called ( moengage . _client . destroy_session ) ;
215+ it ( 'should called update_unique_user_id on calling alias' , function ( ) {
216+ analytics . alias ( 123 ) ;
217+ analytics . called ( moengage . _client . update_unique_user_id ) ;
218+ } ) ;
219+ it ( 'should not called update_unique_user_id on calling alias without new ID' , function ( ) {
220+ analytics . alias ( ) ;
221+ analytics . didNotCall ( moengage . _client . update_unique_user_id ) ;
222+ } ) ;
223+ it ( 'should called update_unique_user_id on calling alias with ID' , function ( ) {
224+ analytics . alias ( 123 ) ;
225+ analytics . called ( moengage . _client . update_unique_user_id , 123 ) ;
226+ } ) ;
227+ it ( 'should not called update_unique_user_id on calling alias with wrong ID' , function ( ) {
228+ analytics . alias ( 123 ) ;
229+ analytics . didNotCall ( moengage . _client . update_unique_user_id , 1234 ) ;
235230 } ) ;
236231 } ) ;
232+
237233 } ) ;
238234} ) ;
0 commit comments