Browse Source

update mock realm object

pull/1/head
Tim Glasgow 2 years ago
parent
commit
8ff7643027
  1. 33
      squarenotsquare/__mock__/mockRealmObject.js

33
squarenotsquare/__mock__/mockRealmObject.js

@ -1,14 +1,14 @@
import { Score } from "../src/realm/entities/Score"; import { ScoreEntity } from "../src/realm/entities/Score";
import { System } from "../src/realm/entities/System"; import { SystemEntity } from "../src/realm/entities/System";
import { User } from "../src/realm/entities/User"; import { UserEntity } from "../src/realm/entities/User";
export class MockRealm{ export default class MockRealm{
constructor(schemaVersion){ constructor(params){
this.schemaVersion = schemaVersion; this.schemaVersion = params.schemaVersion;
this[System.name] = []; this[SystemEntity.name] = [];
this[Score.name] = []; this[ScoreEntity.name] = [];
this[User.name] = []; this[UserEntity.name] = [];
this.deletedKeys = []; this.deletedKeys = [];
} }
@ -29,4 +29,19 @@ export class MockRealm{
delete(key){ delete(key){
this.deletedKeys.push(key); this.deletedKeys.push(key);
} }
static defaultPath = '';
static schemaVersion(path, key){
if (path === 'negTest') {
return -1;
} else if (path === 'breakDB') {
throw 'Existing DB is broken';
} else {
return 0;
}
}
close(){
return null;
}
} }
Loading…
Cancel
Save