Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
testRealmExists: function() {
// Local Realms
let config = {schema: [schemas.TestObject]};
TestCase.assertFalse(Realm.exists(config));
new Realm(config).close();
TestCase.assertTrue(Realm.exists(config));
// Sync Realms
if (!global.enableSyncTests) {
return;
}
return Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.nickname("admin", true))
.then(user => {
const fullSyncConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
fullSynchronization: true,
},
});
TestCase.assertFalse(Realm.exists(fullSyncConfig));
new Realm(fullSyncConfig).close();
testRealmExists: function() {
// Local Realms
let config = {schema: [schemas.TestObject]};
TestCase.assertFalse(Realm.exists(config));
new Realm(config).close();
TestCase.assertTrue(Realm.exists(config));
// Sync Realms
if (!global.enableSyncTests) {
return;
}
return Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.nickname("admin", true))
.then(user => {
const fullSyncConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
fullSynchronization: true,
},
});
.then(user => {
let config = user.createConfiguration({
sync: {
url: 'http://127.0.0.1/new_file_local_' + Utils.uuid(),
newRealmFileBehavior: Realm.Sync.openLocalRealmBehavior,
error: () => {},
}
});
TestCase.assertFalse(Realm.exists(config));
return Realm.open(config);
})
.then(realm => {
fullSynchronization: true,
},
});
TestCase.assertFalse(Realm.exists(fullSyncConfig));
new Realm(fullSyncConfig).close();
TestCase.assertTrue(Realm.exists(fullSyncConfig));
const queryBasedConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
},
});
TestCase.assertFalse(Realm.exists(queryBasedConfig));
new Realm(queryBasedConfig).close();
TestCase.assertTrue(Realm.exists(queryBasedConfig));
});
},
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
fullSynchronization: true,
},
});
TestCase.assertFalse(Realm.exists(fullSyncConfig));
new Realm(fullSyncConfig).close();
TestCase.assertTrue(Realm.exists(fullSyncConfig));
const queryBasedConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
},
});
TestCase.assertFalse(Realm.exists(queryBasedConfig));
new Realm(queryBasedConfig).close();
TestCase.assertTrue(Realm.exists(queryBasedConfig));
});
},
.then(user => {
const fullSyncConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
fullSynchronization: true,
},
});
TestCase.assertFalse(Realm.exists(fullSyncConfig));
new Realm(fullSyncConfig).close();
TestCase.assertTrue(Realm.exists(fullSyncConfig));
const queryBasedConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
},
});
TestCase.assertFalse(Realm.exists(queryBasedConfig));
new Realm(queryBasedConfig).close();
TestCase.assertTrue(Realm.exists(queryBasedConfig));
});
},
.then(user => {
const fullSyncConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
fullSynchronization: true,
},
});
TestCase.assertFalse(Realm.exists(fullSyncConfig));
new Realm(fullSyncConfig).close();
TestCase.assertTrue(Realm.exists(fullSyncConfig));
const queryBasedConfig = user.createConfiguration({
schema: [schemas.TestObject],
sync: {
url: `realm://127.0.0.1:9080/testRealmExists_${Utils.uuid()}`,
},
});
TestCase.assertFalse(Realm.exists(queryBasedConfig));
new Realm(queryBasedConfig).close();
TestCase.assertTrue(Realm.exists(queryBasedConfig));
});
},