Add missing sync error (#925)

* Add missing sync error

* Make unit tests work without sync

* Wording fix
This commit is contained in:
Kristian Dupont 2017-03-22 13:52:41 +01:00 committed by GitHub
parent c4535bdf1a
commit f551a51acc
2 changed files with 10 additions and 3 deletions

View File

@ -66,6 +66,12 @@ 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.
@ -99,4 +105,4 @@ module.exports = function(realmConstructor) {
},
configurable: true
});
}
}

View File

@ -35,10 +35,11 @@ if (!(typeof process === 'object' && process.platform === 'win32')) {
}
// If sync is enabled, run the user tests
if (Realm.Sync) {
try {
Realm.Sync; // This will throw if Sync is disabled.
TESTS.UserTests = require('./user-tests');
TESTS.SessionTests = require('./session-tests');
}
} catch (e) {}
function node_require(module) { return require(module); }