Skip to content

Commit 9256b2d

Browse files
authored
chore: fix flaky test (#3928)
* logOut is async so handle with a promise
1 parent 8b21d5a commit 9256b2d

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

spec/ParseUser.spec.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,29 +1204,30 @@ describe('Parse.User testing', () => {
12041204
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
12051205
ok(model._isLinked("facebook"), "User should be linked to facebook");
12061206

1207-
Parse.User.logOut();
1208-
ok(provider.loggedOut);
1209-
provider.loggedOut = false;
1210-
1211-
Parse.User._logInWith("facebook", {
1212-
success: function(innerModel) {
1213-
ok(innerModel instanceof Parse.User,
1214-
"Model should be a Parse.User");
1215-
ok(innerModel === Parse.User.current(),
1216-
"Returned model should be the current user");
1217-
ok(provider.authData.id === provider.synchronizedUserId);
1218-
ok(provider.authData.access_token === provider.synchronizedAuthToken);
1219-
ok(innerModel._isLinked("facebook"),
1220-
"User should be linked to facebook");
1221-
ok(innerModel.existed(), "User should not be newly-created");
1222-
done();
1223-
},
1224-
error: function(model, error) {
1225-
jfail(error);
1226-
ok(false, "LogIn should have worked");
1227-
done();
1228-
}
1229-
});
1207+
Parse.User.logOut().then(() => {
1208+
ok(provider.loggedOut);
1209+
provider.loggedOut = false;
1210+
1211+
Parse.User._logInWith("facebook", {
1212+
success: function(innerModel) {
1213+
ok(innerModel instanceof Parse.User,
1214+
"Model should be a Parse.User");
1215+
ok(innerModel === Parse.User.current(),
1216+
"Returned model should be the current user");
1217+
ok(provider.authData.id === provider.synchronizedUserId);
1218+
ok(provider.authData.access_token === provider.synchronizedAuthToken);
1219+
ok(innerModel._isLinked("facebook"),
1220+
"User should be linked to facebook");
1221+
ok(innerModel.existed(), "User should not be newly-created");
1222+
done();
1223+
},
1224+
error: function(model, error) {
1225+
jfail(error);
1226+
ok(false, "LogIn should have worked");
1227+
done();
1228+
}
1229+
});
1230+
}, done.fail);
12301231
},
12311232
error: function(model, error) {
12321233
jfail(error);

0 commit comments

Comments
 (0)