Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
testLogout() {
return Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.anonymous()).then((user) => {
assertIsUser(user);
assertIsSameUser(user, Realm.Sync.User.current);
user.logout();
// Is now logged out.
TestCase.assertUndefined(Realm.Sync.User.current);
// Can we open a realm with the registered user?
TestCase.assertThrows(() => new Realm({sync: {user: user, url: 'realm://127.0.0.1:9080/~/test'}}));
});
},
// FIXME: Permission tests currently fail in react native
TESTS.PermissionTests = require('./permission-tests');
node_require('./adapter-tests');
node_require('./notifier-tests');
}
}
// If on node, run the async tests
if (isNodeProcess && process.platform !== 'win32') {
TESTS.AsyncTests = node_require('./async-tests');
}
if (global.enableSyncTests) {
// Ensure that the sync manager is initialized as initializing it
// after calling clearTestState() doesn't work
Realm.Sync.User.all;
}
var SPECIAL_METHODS = {
beforeEach: true,
afterEach: true,
};
exports.getTestNames = function () {
var testNames = {};
for (var suiteName in TESTS) {
var testSuite = TESTS[suiteName];
testNames[suiteName] = Object.keys(testSuite).filter(function (testName) {
return !(testName in SPECIAL_METHODS) && typeof testSuite[testName] == 'function';
});
function pendingOrComplete(state) {
return state === Realm.Sync.SubscriptionState.Pending || state === Realm.Sync.SubscriptionState.Complete;
}
createTestUser: () => {
return Realm.Sync.User.login(
REALM_OBJECT_SERVER_URL,
Realm.Sync.Credentials.nickname(`react-realm-context-tests-${uuid()}`),
);
},
};
function assertIsUser(user, isAdmin) {
TestCase.assertType(user, 'object');
TestCase.assertType(user.token, 'string');
TestCase.assertType(user.identity, 'string');
TestCase.assertInstanceOf(user, Realm.Sync.User);
if (isAdmin !== undefined) {
TestCase.assertEqual(user.isAdmin, isAdmin);
}
}
createTestUser: () => {
return Realm.Sync.User.login(
REALM_OBJECT_SERVER_URL,
Realm.Sync.Credentials.nickname(`react-realm-context-tests-${uuid()}`),
);
},
};
}
scan.faceDetectionResult = faceDetectionResult;
scan.status = kFaceDetectionResultReady;
});
}
});
}
}
}
};
//Create the admin user
var admin_user = Realm.Sync.User.adminUser(REALM_ADMIN_TOKEN, SERVER_URL);
//Callback on Realm changes
Realm.Sync.addListener(SERVER_URL, admin_user, NOTIFIER_PATH, 'change', change_notification_callback);
console.log('Listening for Realm changes across: ' + NOTIFIER_PATH);