Do not throw when the Sync constructor isn’t there (#1086)

* Do not throw when the Sync constructor isn’t there

with unified packaging it’s there all the time now

Closes #1084
Fixes #996

* Fix running the sync tests when Sync is disabled
This commit is contained in:
Yavor Georgiev 2017-06-20 15:40:54 +02:00 committed by GitHub
parent 30e58022cf
commit 7086ed745f
4 changed files with 5 additions and 17 deletions

View File

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

View File

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

View File

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

View File

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