You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
1.5 KiB

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);
});
});