Reset Realm.defaultPath in testDefaultPath

Or else the rest of the tests use the new default path!
This commit is contained in:
Scott Kyle 2016-05-04 15:38:29 -07:00
parent c7e156a7b8
commit 2384cc4036
1 changed files with 10 additions and 5 deletions

View File

@ -145,14 +145,19 @@ module.exports = {
}, },
testDefaultPath: function() { testDefaultPath: function() {
var defaultPath = Realm.defaultPath;
var defaultRealm = new Realm({schema: []}); var defaultRealm = new Realm({schema: []});
TestCase.assertEqual(defaultRealm.path, Realm.defaultPath); TestCase.assertEqual(defaultRealm.path, Realm.defaultPath);
var newPath = Realm.defaultPath.substring(0, Realm.defaultPath.lastIndexOf("/") + 1) + 'default2.realm'; try {
Realm.defaultPath = newPath; var newPath = Realm.defaultPath.substring(0, defaultPath.lastIndexOf('/') + 1) + 'default2.realm';
defaultRealm = new Realm({schema: []}); Realm.defaultPath = newPath;
TestCase.assertEqual(defaultRealm.path, newPath, "should use updated default realm path"); defaultRealm = new Realm({schema: []});
TestCase.assertEqual(Realm.defaultPath, newPath, "defaultPath should have been updated"); 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() { testRealmSchemaVersion: function() {