Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Realm from 'realm';
import { TourStop } from './models/tourStop';
import { AudioContent } from './models/audioContent';
import { Durations } from './models/durations';
const SCHEMAVERSION = 1;
/* eslint-disable */
if (__DEV__) {
// !Undocumented will most likely break in the future!
// Used to delete DB from disk
Realm.clearTestState();
// !End Undocumented will most likely break in the future!
console.log(`Realm DB path is: ${Realm.defaultPath}`);
}
/* eslint-enable */
// *** Realm Instance ***
let realmInstance;
export const getRealmInstance = () => {
if (realmInstance == null) {
realmInstance = new Realm({
schema: [TourStop, AudioContent, Durations],
schemaVersion: SCHEMAVERSION,
migration(oldRealm, newRealm) {
newRealm.deleteAll();
},
beforeEach(() => Realm.clearTestState());
afterEach(() => Realm.clearTestState());
exports.runTest = function (suiteName, testName) {
const testSuite = TESTS[suiteName];
const testMethod = testSuite && testSuite[testName];
if (testMethod) {
Realm.clearTestState();
return testMethod.call(testSuite);
}
if (!testSuite || !(testName in SPECIAL_METHODS)) {
throw new Error(`Missing test: ${suiteName}.${testName}`);
}
}
function() { Realm.clearTestState(); }
);
afterEach(function(done) {
this.rl.close();
this.objectServer.kill('SIGKILL');
this.adminRealm.close();
let reset = spawn("sync-bundle/reset-server-realms.command");
reset.once("close", done);
reset.stdin.write("yes\n");
Realm.clearTestState();
});
async setup(testName) {
if (testName == "insertions" || testName == "binsertions") {
Realm.clearTestState();
}
this.realm = new Realm({schema: [TestObjectSchema]});
await super.setup(testName);
}