Use promisified methods for login and register to have backward compatibility testing as well
This commit is contained in:
parent
b58e9094da
commit
1f5b98bb53
|
@ -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) {
|
function runOutOfProcess(nodeJsFilePath) {
|
||||||
var nodeArgs = Array.prototype.slice.call(arguments);
|
var nodeArgs = Array.prototype.slice.call(arguments);
|
||||||
let tmpDir = tmp.dirSync();
|
let tmpDir = tmp.dirSync();
|
||||||
|
@ -85,7 +111,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
testProperties() {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
|
@ -136,7 +162,7 @@ module.exports = {
|
||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.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;
|
const accessTokenRefreshed = this;
|
||||||
let successCounter = 0;
|
let successCounter = 0;
|
||||||
|
|
||||||
|
@ -446,7 +472,7 @@ module.exports = {
|
||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let config = {
|
let config = {
|
||||||
sync: {
|
sync: {
|
||||||
|
@ -481,7 +507,7 @@ module.exports = {
|
||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let config = {
|
let config = {
|
||||||
sync: {
|
sync: {
|
||||||
|
@ -548,7 +574,7 @@ module.exports = {
|
||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let config = {
|
let config = {
|
||||||
sync: {
|
sync: {
|
||||||
|
@ -587,7 +613,7 @@ module.exports = {
|
||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let config = {
|
let config = {
|
||||||
sync: {
|
sync: {
|
||||||
|
|
Loading…
Reference in New Issue