mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-23 11:48:17 +00:00
address review comments
This commit is contained in:
parent
d5d6638975
commit
9ea5dd7f8c
@ -233,15 +233,15 @@ module.exports = {
|
||||
retrieveAccount(provider, provider_id) {
|
||||
checkTypes(arguments, ['string', 'string']);
|
||||
|
||||
let url = url_parse(this.server);
|
||||
const url = url_parse(this.server);
|
||||
url.set('pathname', `/api/providers/${provider}/accounts/${provider_id}`);
|
||||
let headers = {
|
||||
const headers = {
|
||||
Authorization: this.token
|
||||
};
|
||||
|
||||
const options = {
|
||||
method: 'GET',
|
||||
headers: headers,
|
||||
headers,
|
||||
open_timeout: 5000
|
||||
};
|
||||
return performFetch(url.href, options)
|
||||
|
@ -15,8 +15,6 @@ function random(min, max) {
|
||||
|
||||
exports.createAdminUser = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
let isAdminRetryCounter = 0;
|
||||
let newAdminName = 'admin' + random(1, 100000);
|
||||
let password = '123';
|
||||
@ -39,18 +37,13 @@ exports.createAdminUser = function () {
|
||||
};
|
||||
|
||||
Realm.open(config).then(realm => {
|
||||
if (userIdentity == admin_token_user.identity)
|
||||
{
|
||||
console.log(".");
|
||||
}
|
||||
|
||||
let pendingAdminUser = realm.objects('User').filtered(`id == "${userIdentity}"`)[0];
|
||||
realm.write(() => {
|
||||
pendingAdminUser.isAdmin = true;
|
||||
});
|
||||
|
||||
admin_token_user.logout();
|
||||
}).then(_ => {
|
||||
}).then(() => {
|
||||
let waitForServerToUpdateAdminUser = function () {
|
||||
isAdminRetryCounter++;
|
||||
if (isAdminRetryCounter > 10) {
|
||||
@ -65,7 +58,7 @@ exports.createAdminUser = function () {
|
||||
let isAdmin = newAdminUser.isAdmin;
|
||||
user.logout();
|
||||
if (!isAdmin) {
|
||||
setTimeout(_ => {
|
||||
setTimeout(() => {
|
||||
waitForServerToUpdateAdminUser();
|
||||
}, 500);
|
||||
return;
|
||||
@ -73,7 +66,7 @@ exports.createAdminUser = function () {
|
||||
|
||||
resolve({
|
||||
username: newAdminName,
|
||||
password: password
|
||||
password
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ Realm.Sync.User.register('http://localhost:9080', username, 'password', (error,
|
||||
});
|
||||
|
||||
console.log("Dogs count " + realm.objects('Dog').length);
|
||||
setTimeout(_ => process.exit(0), 3000);
|
||||
setTimeout(() => process.exit(0), 3000);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -44,8 +44,8 @@ if (Realm.Sync) {
|
||||
function node_require(module) { return require(module); }
|
||||
|
||||
// If on node, run the async tests
|
||||
global.isNodeProcess = typeof process === 'object' && process + '' === '[object process]'
|
||||
if (global.isNodeProcess) {
|
||||
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
||||
if (isNodeProcess) {
|
||||
TESTS.AsyncTests = node_require('./async-tests');
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ exports.registerTests = function(tests) {
|
||||
};
|
||||
|
||||
exports.prepare = function(done) {
|
||||
if (!global.isNodeProcess || global.testAdminUserInfo) {
|
||||
if (!isNodeProcess || global.testAdminUserInfo) {
|
||||
done();
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
const Realm = require('realm');
|
||||
const TestCase = require('./asserts');
|
||||
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
||||
|
||||
function uuid() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
@ -297,7 +298,7 @@ module.exports = {
|
||||
|
||||
testRetrieveAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!global.isNodeProcess) {
|
||||
if (!isNodeProcess) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ module.exports = {
|
||||
|
||||
testRetrieveNotExistingAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!global.isNodeProcess) {
|
||||
if (!isNodeProcess) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user