From 2384cc40361b040b59bb0d7e5d7dfcdbe6e60437 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 4 May 2016 15:38:29 -0700 Subject: [PATCH] Reset Realm.defaultPath in testDefaultPath Or else the rest of the tests use the new default path! --- tests/js/realm-tests.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 6a9ba6b8..fe966347 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -145,14 +145,19 @@ module.exports = { }, testDefaultPath: function() { + var defaultPath = Realm.defaultPath; var defaultRealm = new Realm({schema: []}); TestCase.assertEqual(defaultRealm.path, Realm.defaultPath); - var newPath = Realm.defaultPath.substring(0, Realm.defaultPath.lastIndexOf("/") + 1) + 'default2.realm'; - Realm.defaultPath = newPath; - defaultRealm = new Realm({schema: []}); - TestCase.assertEqual(defaultRealm.path, newPath, "should use updated default realm path"); - TestCase.assertEqual(Realm.defaultPath, newPath, "defaultPath should have been updated"); + try { + var newPath = Realm.defaultPath.substring(0, defaultPath.lastIndexOf('/') + 1) + 'default2.realm'; + Realm.defaultPath = newPath; + defaultRealm = new Realm({schema: []}); + TestCase.assertEqual(defaultRealm.path, newPath, "should use updated default realm path"); + TestCase.assertEqual(Realm.defaultPath, newPath, "defaultPath should have been updated"); + } finally { + Realm.defaultPath = defaultPath; + } }, testRealmSchemaVersion: function() {