diff --git a/tests/js/encryption-tests.js b/tests/js/encryption-tests.js index 14926b5e..f8c9f68c 100644 --- a/tests/js/encryption-tests.js +++ b/tests/js/encryption-tests.js @@ -69,24 +69,21 @@ module.exports = { Realm.schemaVersion('encrypted.realm', 'asdf'); }); }, -}; + testEncryptionWithSync: function() { + if (!global.enableSyncTests) { + return Promise.resolve(); + } -if (global.enableSyncTests) { - module.exports.testEncryptionWithSync = function() { - Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => { - if (error) { - reject(error); - } + return Realm.Sync.User.login('http://localhost:9080', "realm-admin", '').then(adminUser => { new Realm({ encryptionKey: new Int8Array(64), sync: { - user: user, + user: adminUser, url: 'realm://localhost:9080' } }); - user.logout(); // FIXME: clearTestState() doesn't clean up enough and Realm.Sync.User.current might not work - resolve(); + adminUser.logout(); // FIXME: clearTestState() doesn't clean up enough and Realm.Sync.User.current might not work }); } -} +}; diff --git a/tests/js/index.js b/tests/js/index.js index 06d4be55..b0f57f5c 100644 --- a/tests/js/index.js +++ b/tests/js/index.js @@ -20,7 +20,11 @@ const Realm = require('realm'); -global.enableSyncTests = Realm.Sync; + +if( typeof Realm.Sync !== 'undefined' && Realm.Sync !== null ) { + global.WARNING = "global is not available in React Native. Use it only in tests"; + global.enableSyncTests = true; +} const isNodeProcess = typeof process === 'object' && process + '' === '[object process]'; function node_require(module) { return require(module); }