fix tests.

This commit is contained in:
Jason Kulatunga 2022-10-17 20:29:04 -07:00
parent 09d667b5e5
commit 62b795319e
6 changed files with 25 additions and 9 deletions

View File

@ -1,12 +1,14 @@
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
RouterTestingModule,
HttpClientTestingModule
],
declarations: [
AppComponent

View File

@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EncryptionManagerComponent } from './encryption-manager.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('EncryptionManagerComponent', () => {
let component: EncryptionManagerComponent;
@ -8,7 +9,9 @@ describe('EncryptionManagerComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EncryptionManagerComponent ]
declarations: [ EncryptionManagerComponent ],
imports: [HttpClientTestingModule],
})
.compileComponents();

View File

@ -1,12 +1,15 @@
import { TestBed } from '@angular/core/testing';
import { QueueService } from './queue.service';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('QueueService', () => {
let service: QueueService;
beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});
service = TestBed.inject(QueueService);
});

View File

@ -2,7 +2,7 @@ import {FHIR401Client} from './fhir401_r4_client';
import {Source} from '../../../models/database/source';
import {IResourceBundleRaw} from '../../interface';
import {ResourceFhir} from '../../../models/database/resource_fhir';
import {NewRepositiory} from '../../../database/pouchdb_repository';
import {NewPouchdbRepositoryWebWorker} from '../../../database/pouchdb_repository';
import {Base64} from '../../../utils/base64';
import * as PouchDB from 'pouchdb/dist/pouchdb';
import { v4 as uuidv4 } from 'uuid';
@ -10,6 +10,7 @@ import { v4 as uuidv4 } from 'uuid';
// @ts-ignore
import * as FHIR401Client_ProcessBundle from './fixtures/FHIR401Client_ProcessBundle.json';
import {IDatabaseRepository} from '../../../database/interface';
import {PouchdbCrypto} from '../../../database/plugins/crypto';
class TestClient extends FHIR401Client {
@ -66,7 +67,10 @@ describe('FHIR401Client', () => {
let repository: IDatabaseRepository;
beforeEach(async () => {
repository = NewRepositiory(null, null, new PouchDB("FHIR401Client-"+ uuidv4()));
let current_user = uuidv4()
let cryptoConfig = await PouchdbCrypto.CryptConfig(current_user, current_user)
await PouchdbCrypto.StoreCryptConfig(cryptoConfig)
repository = NewPouchdbRepositoryWebWorker(current_user, new PouchDB("FHIR401Client-"+ current_user));
});
afterEach(async () => {

View File

@ -1,16 +1,20 @@
import {IDatabaseRepository} from './interface';
import {NewRepositiory} from './pouchdb_repository';
import {NewPouchdbRepositoryWebWorker} from './pouchdb_repository';
import {SourceType} from '../models/database/source_types';
import {Source} from '../models/database/source';
import {DocType} from './constants';
import * as PouchDB from 'pouchdb/dist/pouchdb';
import { v4 as uuidv4 } from 'uuid';
import {PouchdbCrypto} from './plugins/crypto';
describe('PouchdbRepository', () => {
let repository: IDatabaseRepository;
beforeEach(async () => {
repository = NewRepositiory(null, null, new PouchDB("PouchdbRepository" + uuidv4()));
let current_user = uuidv4()
let cryptoConfig = await PouchdbCrypto.CryptConfig(current_user, current_user)
await PouchdbCrypto.StoreCryptConfig(cryptoConfig)
repository = NewPouchdbRepositoryWebWorker(current_user, new PouchDB("PouchdbRepository" + current_user));
});
afterEach(async () => {

View File

@ -49,8 +49,8 @@ import {PouchdbCryptConfig, PouchdbCrypto, PouchdbCryptoOptions} from './plugins
* @constructor
*/
export function NewPouchdbRepositoryWebWorker(current_user: string): PouchdbRepository {
let pouchdbRepository = new PouchdbRepository()
export function NewPouchdbRepositoryWebWorker(current_user: string, localPouchDb?: PouchDB.Database): PouchdbRepository {
let pouchdbRepository = new PouchdbRepository(localPouchDb)
pouchdbRepository.current_user = current_user
return pouchdbRepository
}