address review comments

This commit is contained in:
blagoev 2017-07-07 16:38:13 +03:00
parent d5d6638975
commit 9ea5dd7f8c
5 changed files with 13 additions and 19 deletions

View File

@ -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)

View File

@ -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
});
}
});

View File

@ -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);
}
});

View File

@ -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();
}

View File

@ -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();
}