@@ -34,7 +34,7 @@ describe('mParticleUser', function() {
3434 fetchMock . restore ( ) ;
3535 } ) ;
3636
37- it ( 'should call forwarder onUserIdentified method with a filtered user identity list' , function ( done ) {
37+ it ( 'should call forwarder onUserIdentified method with a filtered user identity list' , async ( ) => {
3838 mParticle . _resetForTests ( MPConfig ) ;
3939 const mockForwarder = new MockForwarder ( ) ;
4040
@@ -45,8 +45,8 @@ describe('mParticleUser', function() {
4545 window . mParticle . config . kitConfigs . push ( config1 ) ;
4646
4747 mParticle . init ( apiKey , window . mParticle . config ) ;
48- waitForCondition ( hasIdentifyReturned )
49- . then ( ( ) => {
48+ await waitForCondition ( hasIdentifyReturned ) ;
49+
5050 const userIdentityRequest = {
5151 userIdentities : {
5252 google : 'test' ,
@@ -55,13 +55,13 @@ describe('mParticleUser', function() {
5555 } ,
5656 } ;
5757 mParticle . Identity . login ( userIdentityRequest ) ;
58- waitForCondition ( ( ) => {
58+ await waitForCondition ( ( ) => {
5959 return (
6060 mParticle . Identity . getCurrentUser ( ) ?. getMPID ( ) ===
6161 'loginMPID'
6262 ) ;
63- } )
64- . then ( ( ) => {
63+ } ) ;
64+
6565 window . MockForwarder1 . instance . onUserIdentifiedUser
6666 . getUserIdentities ( )
6767 . userIdentities . should . not . have . property ( 'google' ) ;
@@ -71,12 +71,9 @@ describe('mParticleUser', function() {
7171 window . MockForwarder1 . instance . onUserIdentifiedUser
7272 . getUserIdentities ( )
7373 . userIdentities . should . have . property ( 'other' , 'id2' ) ;
74- done ( ) ;
75- } )
76- } )
7774 } ) ;
7875
79- it ( 'should call forwarder onUserIdentified method with a filtered user attributes list' , function ( done ) {
76+ it ( 'should call forwarder onUserIdentified method with a filtered user attributes list' , async ( ) => {
8077 mParticle . _resetForTests ( MPConfig ) ;
8178 const mockForwarder = new MockForwarder ( ) ;
8279
@@ -89,8 +86,8 @@ describe('mParticleUser', function() {
8986
9087 mParticle . init ( apiKey , window . mParticle . config ) ;
9188
92- waitForCondition ( hasIdentifyReturned )
93- . then ( ( ) => {
89+ await waitForCondition ( hasIdentifyReturned ) ;
90+
9491 const userIdentityRequest = {
9592 userIdentities : {
9693 google : 'test' ,
@@ -100,13 +97,13 @@ describe('mParticleUser', function() {
10097 } ;
10198
10299 mParticle . Identity . login ( userIdentityRequest ) ;
103- waitForCondition ( ( ) => {
100+ await waitForCondition ( ( ) => {
104101 return (
105102 mParticle . Identity . getCurrentUser ( ) ?. getMPID ( ) ===
106103 'loginMPID'
107104 ) ;
108- } )
109- . then ( ( ) => { } ) ;
105+ } ) ;
106+
110107 mParticle . Identity . getCurrentUser ( ) . setUserAttribute ( 'gender' , 'male' ) ;
111108 mParticle . Identity . getCurrentUser ( ) . setUserAttribute ( 'color' , 'blue' ) ;
112109 mParticle . Identity . login ( userIdentityRequest ) ;
@@ -116,12 +113,9 @@ describe('mParticleUser', function() {
116113 window . MockForwarder1 . instance . onUserIdentifiedUser
117114 . getAllUserAttributes ( )
118115 . should . have . property ( 'color' , 'blue' ) ;
119-
120- done ( ) ;
121- } ) ;
122116 } ) ;
123117
124- it ( 'should call forwarder onIdentifyComplete' , function ( done ) {
118+ it ( 'should call forwarder onIdentifyComplete' , async ( ) => {
125119 mParticle . _resetForTests ( MPConfig ) ;
126120 const mockForwarder = new MockForwarder ( ) ;
127121
@@ -134,14 +128,12 @@ describe('mParticleUser', function() {
134128
135129 mParticle . init ( apiKey , window . mParticle . config ) ;
136130
137- waitForCondition ( hasIdentifyReturned )
138- . then ( ( ) => {
131+ await waitForCondition ( hasIdentifyReturned ) ;
132+
139133 window . MockForwarder1 . instance . onIdentifyCompleteCalled . should . equal ( true ) ;
140- done ( ) ;
141- } )
142134 } ) ;
143135
144- it ( 'should call forwarder onLoginComplete' , function ( done ) {
136+ it ( 'should call forwarder onLoginComplete' , async ( ) => {
145137 mParticle . _resetForTests ( MPConfig ) ;
146138 const mockForwarder = new MockForwarder ( ) ;
147139
@@ -154,8 +146,8 @@ describe('mParticleUser', function() {
154146
155147 mParticle . init ( apiKey , window . mParticle . config ) ;
156148
157- waitForCondition ( hasIdentifyReturned )
158- . then ( ( ) => {
149+ await waitForCondition ( hasIdentifyReturned ) ;
150+
159151 const userIdentityRequest = {
160152 userIdentities : {
161153 google : 'test' ,
@@ -165,20 +157,17 @@ describe('mParticleUser', function() {
165157 } ;
166158
167159 mParticle . Identity . login ( userIdentityRequest ) ;
168- waitForCondition ( ( ) => {
160+ await waitForCondition ( ( ) => {
169161 return (
170162 mParticle . Identity . getCurrentUser ( ) ?. getMPID ( ) ===
171163 'loginMPID'
172164 ) ;
173- } )
174- . then ( ( ) => {
175- window . MockForwarder1 . instance . onLoginCompleteCalled . should . equal ( true ) ;
176- done ( ) ;
177165 } ) ;
178- } )
166+
167+ window . MockForwarder1 . instance . onLoginCompleteCalled . should . equal ( true ) ;
179168 } ) ;
180169
181- it ( 'should call forwarder onLogoutComplete' , function ( done ) {
170+ it ( 'should call forwarder onLogoutComplete' , async ( ) => {
182171 mParticle . _resetForTests ( MPConfig ) ;
183172 const mockForwarder = new MockForwarder ( ) ;
184173
@@ -191,8 +180,8 @@ describe('mParticleUser', function() {
191180
192181 mParticle . init ( apiKey , window . mParticle . config ) ;
193182
194- waitForCondition ( hasIdentifyReturned )
195- . then ( ( ) => {
183+ await waitForCondition ( hasIdentifyReturned ) ;
184+
196185 const userIdentityRequest = {
197186 userIdentities : {
198187 google : 'test' ,
@@ -202,20 +191,17 @@ describe('mParticleUser', function() {
202191 } ;
203192
204193 mParticle . Identity . logout ( userIdentityRequest ) ;
205- waitForCondition ( ( ) => {
194+ await waitForCondition ( ( ) => {
206195 return (
207196 mParticle . Identity . getCurrentUser ( ) ?. getMPID ( ) ===
208197 'logoutMPID'
209198 ) ;
210- } )
211- . then ( ( ) => {
212- window . MockForwarder1 . instance . onLogoutCompleteCalled . should . equal ( true ) ;
213- done ( ) ;
214- } ) ;
215- } )
199+ } ) ;
200+
201+ window . MockForwarder1 . instance . onLogoutCompleteCalled . should . equal ( true ) ;
216202 } ) ;
217203
218- it ( 'should call forwarder onModifyComplete method with the proper identity method passed through' , function ( done ) {
204+ it ( 'should call forwarder onModifyComplete method with the proper identity method passed through' , async ( ) => {
219205 mParticle . _resetForTests ( MPConfig ) ;
220206 const mockForwarder = new MockForwarder ( ) ;
221207
@@ -228,8 +214,8 @@ describe('mParticleUser', function() {
228214
229215 mParticle . init ( apiKey , window . mParticle . config ) ;
230216
231- waitForCondition ( hasIdentifyReturned )
232- . then ( ( ) => {
217+ await waitForCondition ( hasIdentifyReturned ) ;
218+
233219 const userIdentityRequest = {
234220 userIdentities : {
235221 google : 'test' ,
@@ -243,16 +229,13 @@ describe('mParticleUser', function() {
243229 } ) ;
244230
245231 mParticle . Identity . modify ( userIdentityRequest ) ;
246- waitForCondition ( ( ) => {
232+ await waitForCondition ( ( ) => {
247233 return (
248234 mParticle . Identity . getCurrentUser ( ) ?. getMPID ( ) ===
249235 'modifyMPID'
250236 ) ;
251- } )
252- . then ( ( ) => {
237+ } ) ;
238+
253239 window . MockForwarder1 . instance . onModifyCompleteCalled . should . equal ( true ) ;
254- done ( ) ;
255- } ) ;
256- } )
257240 } ) ;
258241} ) ;
0 commit comments