Skip to content

Fix flaky tests #3724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions spec/AuthenticationAdapters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ describe('AuthenticationProviers', function() {
var provider = require("../src/Adapters/Auth/" + providerName);
jequal(typeof provider.validateAuthData, "function");
jequal(typeof provider.validateAppId, "function");
jequal(provider.validateAuthData({}, {}).constructor, Promise.prototype.constructor);
jequal(provider.validateAppId("app", "key", {}).constructor, Promise.prototype.constructor);
const authDataPromise = provider.validateAuthData({}, {});
const validateAppIdPromise = provider.validateAppId("app", "key", {});
jequal(authDataPromise.constructor, Promise.prototype.constructor);
jequal(validateAppIdPromise.constructor, Promise.prototype.constructor);
authDataPromise.then(()=>{}, ()=>{});
validateAppIdPromise.then(()=>{}, ()=>{});
done();
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ function graphRequest(path) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ function request(path, access_token) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ function request(path) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
9 changes: 7 additions & 2 deletions src/Adapters/Auth/janrainengage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function request(api_key, auth_token) {
}
};

return new Promise(function (resolve) {
return new Promise(function (resolve, reject) {
// Create the post request.
var post_req = https.request(post_options, function (res) {
var data = '';
Expand All @@ -52,7 +52,12 @@ function request(api_key, auth_token) {
});
// Once we have all the data, we can parse it and return the data we want.
res.on('end', function () {
resolve(JSON.parse(data));
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
});

Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/linkedin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ function request(path, access_token, is_mobile_sdk) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/meetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ function request(path, access_token) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/qq.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ function graphRequest(path) {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'qq auth is invalid for this user.');
}
data = data.substring(starPos + 1,endPos - 1);
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function () {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function request(path, access_token) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function() {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/vkontakte.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ function request(host, path) {
data += chunk;
});
res.on('end', function () {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function () {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/wechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ function graphRequest(path) {
data += chunk;
});
res.on('end', function () {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
}).on('error', function () {
Expand Down
6 changes: 5 additions & 1 deletion src/Adapters/Auth/weibo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ function graphRequest(access_token) {
data += chunk;
});
res.on('end', function () {
data = JSON.parse(data);
try {
data = JSON.parse(data);
} catch(e) {
return reject(e);
}
resolve(data);
});
res.on('error', function () {
Expand Down