diff --git a/CHANGELOG.md b/CHANGELOG.md index 4986f38a..f04d6170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ vNext Release notes (TBD) * None ### Enhancements +* Accessing `Realm.Sync` when sync is not enabled will no longer throw, but return `undefined`. * Better error messages when creating objects. * Added bundled TypeScript declarations of the Realm API. diff --git a/lib/extensions.js b/lib/extensions.js index 76d1918f..c8f3d339 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -94,12 +94,6 @@ module.exports = function(realmConstructor) { setConstructorOnPrototype(realmConstructor.Sync.User); setConstructorOnPrototype(realmConstructor.Sync.Session); - } else { - Object.defineProperty(realmConstructor, 'Sync', { - get: function () { - throw new Error("Realm.Sync is not available. Note that the developer edition of the Node.JS SDK for Realm does not include sync on Linux."); - } - }) } // TODO: Remove this now useless object. diff --git a/tests/js/encryption-tests.js b/tests/js/encryption-tests.js index 27356ed3..f5d3974b 100644 --- a/tests/js/encryption-tests.js +++ b/tests/js/encryption-tests.js @@ -71,8 +71,7 @@ module.exports = { }, }; -try { - Realm.Sync; // this will throw is sync is disabled +if (Realm.Sync) { module.exports.testEncryptionWithSync = function() { new Realm({ encryptionKey: new Int8Array(64), @@ -82,4 +81,4 @@ try { } }); }; -} catch(e) { } +} diff --git a/tests/js/index.js b/tests/js/index.js index 5b6580f8..4c954735 100644 --- a/tests/js/index.js +++ b/tests/js/index.js @@ -34,14 +34,8 @@ if (!(typeof process === 'object' && process.platform === 'win32')) { TESTS.EncryptionTests = require('./encryption-tests'); } -// If sync is enabled, run the user tests -let hasSync = false; -try { - Realm.Sync; // This will throw if Sync is disabled. - hasSync = true; -} catch (e) { } - -if (hasSync) { +// If sync is enabled, run the sync tests +if (Realm.Sync) { TESTS.UserTests = require('./user-tests'); TESTS.SessionTests = require('./session-tests'); }