import { initDB } from '../src/realm/dbInit'; import dbAPI from '../src/realm/dbAPI'; test('Realm DB inits', () => { return initDB('negTest', 'negTest') .then( (dbRef) => { expect(dbRef).toEqual(expect.anything()); }); }); test('Realm DB inits with no existing key', () => { return initDB('isNull', 'isNull') .then( (dbRef) => { expect(dbRef).toEqual(expect.anything()); }); }); test('Realm DB inits with existing DB', () => { return initDB() .then( (dbRef) => { expect(dbRef).toEqual(expect.anything()); }); }); test('Realm DB returns null after exceptions', () => { return initDB('breakDB', 'breakDB') .then( (dbRef) => { expect(dbRef).toEqual(null); }); }); test('dbAPI calls system repo getAllSystemValues()', () => { return initDB('isNull', 'isNull') .then( () => { let returned = dbAPI.getAllSystemValues(); expect(returned).toEqual({}); }); }); test('dbAPI calls system repo createSystemValue()', () => { return initDB('isNull', 'isNull') .then( () => { let returned = dbAPI.createSystemValue(); expect(returned).toEqual(true); }); }); test('dbAPI calls system repo deleteSystemValue()', () => { return initDB('isNull', 'isNull') .then( () => { let returned = dbAPI.deleteSystemValue(); expect(returned).toEqual(true); }); }); test('dbAPI calls system repo getSystemValue()', () => { return initDB('isNull', 'isNull') .then( () => { let returned = dbAPI.getSystemValue('notakey'); expect(returned.id).toEqual(null); }); });