Fix download api for RN

fix tests when run in RN
This commit is contained in:
blagoev 2017-05-12 15:38:44 +03:00
parent 0d3fbccbe1
commit a0f963775b
2 changed files with 21 additions and 10 deletions

View File

@ -50,7 +50,8 @@ module.exports = function(realmConstructor) {
}
let syncedRealm = new realmConstructor(config);
setTimeout(_ => { resolve(syncedRealm); }, 1); //FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { resolve(syncedRealm); }, 1);
});
});
},
@ -62,7 +63,8 @@ module.exports = function(realmConstructor) {
}
let syncedRealm = new realmConstructor(config);
callback(null, syncedRealm);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { callback(null, syncedRealm); }, 1);
});
},
}));

View File

@ -22,11 +22,24 @@
const Realm = require('realm');
const TestCase = require('./asserts');
const tmp = require('tmp');
const fs = require('fs');
const execFile = require('child_process').execFile;
const isNodeProccess = (typeof process === 'object' && process + '' === '[object process]');
console.log("isnode " + isNodeProccess + " typeof " + typeof process === 'object');
function node_require(module) {
return require(module);
}
let tmp;
let fs;
let execFile;
if (isNodeProccess) {
tmp = node_require('tmp');
fs = node_require('fs');
execFile = node_require('child_process').execFile;
tmp.setGracefulCleanup();
}
function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
@ -110,8 +123,6 @@ module.exports = {
},
testRealmOpen() {
const isNodeProccess = typeof process === 'object';
if (!isNodeProccess) {
return Promise.resolve();
}
@ -164,8 +175,6 @@ module.exports = {
},
testRealmOpenAsync() {
const isNodeProccess = typeof process === 'object';
if (!isNodeProccess) {
return Promise.resolve();
}