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() {
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() {