Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Realm.Sync.User.login('http://127.0.0.1:9080', credentials).then(user => {
let config = {
sync: {
user: user,
url: 'realm://127.0.0.1:9080/~/default',
fullSynchronization: true, // <---- calling subscribe should fail
error: (session, error) => console.log(error)
},
schema: [{ name: 'Dog', properties: { name: 'string' } }]
};
Realm.deleteFile(config);
const realm = new Realm(config);
TestCase.assertEqual(realm.objects('Dog').length, 0);
TestCase.assertThrows(() => realm.objects('Dog').filtered("name == 'Lassy 1'").subscribe());
realm.close();
});
},
// Full sync shouldn't include the permission schema
config = {
schema: [],
sync: {
user: user,
url: `realm://NO_SERVER/foo`,
fullSynchronization: true
}
};
realm = new Realm(config);
TestCase.assertTrue(realm.empty);
TestCase.assertEqual(realm.schema.length, 0);
realm.close();
Realm.deleteFile(config);
});
},
.then(realm => {
const user = realm.syncSession.user;
const config = user.createConfiguration();
realm.close();
Realm.deleteFile(config);
// connecting with an empty schema should be possible, permission is added implicitly
return Realm.open(config);
})
.then(realm => {
fullSynchronization: false,
}
};
let realm = new Realm(config);
TestCase.assertTrue(realm.empty);
TestCase.assertEqual(realm.schema.length, 5 + 1); // 5 = see below, 1 = __ResultSets
TestCase.assertEqual(realm.schema.filter(schema => schema.name === '__Class').length, 1);
TestCase.assertEqual(realm.schema.filter(schema => schema.name === '__Permission').length, 1);
TestCase.assertEqual(realm.schema.filter(schema => schema.name === '__Realm').length, 1);
TestCase.assertEqual(realm.schema.filter(schema => schema.name === '__Role').length, 1);
TestCase.assertEqual(realm.schema.filter(schema => schema.name === '__User').length, 1);
realm.close();
Realm.deleteFile(config);
// Full sync shouldn't include the permission schema
config = {
schema: [],
sync: {
user: user,
url: `realm://NO_SERVER/foo`,
fullSynchronization: true
}
};
realm = new Realm(config);
TestCase.assertTrue(realm.empty);
TestCase.assertEqual(realm.schema.length, 0);
realm.close();
Realm.deleteFile(config);
.then(pathExistBeforeDelete => {
TestCase.assertTrue(pathExistBeforeDelete);
Realm.deleteFile(config);
return fs.exists(path)
})
.then(pathExistAfterDelete => {
let callback = (transferred, total) => {
if (transferred >= total) {
session.removeProgressNotification(callback);
realm.close();
Realm.deleteFile(userConfig);
resolve(user.serialize());
}
}
session.addProgressNotification('upload', 'forCurrentlyOutstandingWork', callback);