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.
63 lines
1.6 KiB
63 lines
1.6 KiB
import { initDB } from '../src/realm/DbInit';
|
|
import DbAPI from '../src/realm/DbAPI';
|
|
jest.useRealTimers();
|
|
|
|
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 DbAPI.initDB('isNull', 'isNull')
|
|
.then( () => {
|
|
let returned = DbAPI.getAllSystemValues();
|
|
expect(returned).toEqual({});
|
|
});
|
|
});
|
|
|
|
test('dbAPI calls system repo createSystemValue()', () => {
|
|
return DbAPI.initDB('isNull', 'isNull')
|
|
.then( () => {
|
|
let returned = DbAPI.createSystemValue();
|
|
expect(returned).toEqual(true);
|
|
});
|
|
});
|
|
|
|
test('dbAPI calls system repo deleteSystemValue()', () => {
|
|
return DbAPI.initDB('isNull', 'isNull')
|
|
.then( () => {
|
|
let returned = DbAPI.deleteSystemValue();
|
|
expect(returned).toEqual(true);
|
|
});
|
|
});
|
|
|
|
test('dbAPI calls system repo getSystemValue()', () => {
|
|
return DbAPI.initDB('isNull', 'isNull')
|
|
.then( () => {
|
|
let returned = DbAPI.getSystemValue('notakey');
|
|
expect(returned.id).toEqual(null);
|
|
});
|
|
});
|