Use promisified methods for login and register to have backward compatibility testing as well

This commit is contained in:
blagoev 2017-09-12 23:08:54 +03:00
parent b58e9094da
commit 1f5b98bb53
1 changed files with 32 additions and 6 deletions

View File

@ -50,6 +50,32 @@ function uuid() {
});
}
function promisifiedRegister(server, username, password) {
return new Promise((resolve, reject) => {
Realm.Sync.User.register(server, username, password, (error, user) => {
if (error) {
console.log(`promisifiedRegister ${error}`);
reject(error);
} else {
resolve(user);
}
});
});
}
function promisifiedLogin(server, username, password) {
return new Promise((resolve, reject) => {
Realm.Sync.User.login(server, username, password, (error, user) => {
if (error) {
console.log(`promisifiedLogin ${error}`);
reject(error);
} else {
resolve(user);
}
});
});
}
function runOutOfProcess(nodeJsFilePath) {
var nodeArgs = Array.prototype.slice.call(arguments);
let tmpDir = tmp.dirSync();
@ -85,7 +111,7 @@ module.exports = {
},
testProperties() {
return Realm.Sync.User.login('http://localhost:9080', uuid(), 'password').then(user => {
return promisifiedRegister('http://localhost:9080', uuid(), 'password').then(user => {
return new Promise((resolve, reject) => {
const accessTokenRefreshed = this;
@ -136,7 +162,7 @@ module.exports = {
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
.then(() => {
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
const accessTokenRefreshed = this;
let successCounter = 0;
@ -446,7 +472,7 @@ module.exports = {
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
.then(() => {
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
return new Promise((resolve, reject) => {
let config = {
sync: {
@ -481,7 +507,7 @@ module.exports = {
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
.then(() => {
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
return new Promise((resolve, reject) => {
let config = {
sync: {
@ -548,7 +574,7 @@ module.exports = {
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
.then(() => {
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
return new Promise((resolve, reject) => {
let config = {
sync: {
@ -587,7 +613,7 @@ module.exports = {
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
.then(() => {
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
return new Promise((resolve, reject) => {
let config = {
sync: {