Browse Source

rename repo tests

pull/1/head
Tim Glasgow 2 years ago
parent
commit
8109e8a1ae
  1. 75
      squarenotsquare/__tests__/Repo-test.js
  2. 18
      squarenotsquare/__tests__/Repo-tests.js

75
squarenotsquare/__tests__/Repo-test.js

@ -0,0 +1,75 @@
import ScoreRepo from "../src/realm/repos/ScoreRepo";
import SystemRepo from "../src/realm/repos/SystemRepo";
import UserRepo from "../src/realm/repos/UserRepo";
import { System } from "../src/realm/entities/System";
import { MockRealm } from "../__mock__/mockRealmObject";
import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';
test('ScoreRepo inits', () => {
let testRepo = new ScoreRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
test('SystemRepo inits', () => {
let testRepo = new SystemRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
test('UserRepo inits', () => {
let testRepo = new UserRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
test('SystemRepo gets all values', () => {
let mockRealm = new MockRealm(0);
let testRepo = new SystemRepo(mockRealm);
let systemKey1 = {
id: uuidv4(),
key: 'key1',
value: 'val1'
};
let systemKey2 = {
id: uuidv4(),
key: 'key2',
value: 'val2'
};
mockRealm.create(System.name, systemKey1);
mockRealm.create(System.name, systemKey2);
let queried = testRepo.getAllSystemValues();
expect(queried[systemKey1.key]).toEqual('val1');
expect(queried[systemKey2.key]).toEqual('val2');
})
test('SystemRepo creates system value', () => {
let mockRealm = new MockRealm(0);
let testRepo = new SystemRepo(mockRealm);
let newSystemKey = {
key: 'newKey',
value: 'isNew'
};
testRepo.createSystemValue(newSystemKey.key, newSystemKey.value);
let object = mockRealm[System.name][0];
expect(object.value).toEqual('isNew');
})
test('SystemRepo deletes existing system value', () => {
let mockRealm = new MockRealm(0);
let testRepo = new SystemRepo(mockRealm);
let newSystemKey = {
key: 'newKey',
value: 'isNew'
};
testRepo.createSystemValue(newSystemKey.key, newSystemKey.value);
testRepo.deleteSystemValue(newSystemKey.key);
expect(mockRealm.deletedKeys[0].value).toEqual(newSystemKey.value);
})

18
squarenotsquare/__tests__/Repo-tests.js

@ -1,18 +0,0 @@
import ScoreRepo from "../src/realm/repos/ScoreRepo";
import SystemRepo from "../src/realm/repos/SystemRepo";
import UserRepo from "../src/realm/repos/UserRepo";
test('ScoreRepo inits', () => {
let testRepo = new ScoreRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
test('SystemRepo inits', () => {
let testRepo = new SystemRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
test('UserRepo inits', () => {
let testRepo = new UserRepo({fakeRealm: true});
expect(testRepo.realmDB.fakeRealm).toEqual(true);
})
Loading…
Cancel
Save