All files / src/dev/testClass TestModule.ts

93.75% Statements 15/16
90% Branches 9/10
100% Functions 3/3
93.75% Lines 15/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                    1x 1x 1x 1x     1x         1x 1x 1x 1x 1x 1x 1x 1x 1x       2x      
import {
  CoreBundleModule,
  CoreCache,
  CoreClient,
  CoreDBCon,
  CoreDBPrefab,
  CorePresenter,
} from '../../classes';
import { CoreCryptoClient, InMemCache, InMemDB } from '../../modules';
import { BackgroundService } from '../../services';
import TestClient from './client/TestClient';
import TestAction from './action/TestAction';
import TestPresenter from './client/TestPresenter';
import TestPrefab from './db/TestPrefab';
import CoreKernel from '../../CoreKernel';
import TestTriggerService from './service/TestTriggerService';
 
export type TestFc = (mod: TestModule) => TestInterface;
export type TestInterface = {
  db?: CoreDBCon<any, any>;
  cache?: CoreCache | null;
  presenter?: CorePresenter<any>;
  client?: CoreClient;
};
export default class TestModule extends CoreBundleModule<
  CoreKernel<CoreCryptoClient>,
  CoreDBPrefab<any>,
  TestClient,
  CoreCache,
  TestPresenter
> {
  testInterface: TestInterface | null;
 
  constructor(kernel: CoreKernel<CoreCryptoClient>, init?: TestFc) {
    super('testModule', kernel);
    this.addAction(new TestAction(this));
    this.addService(new BackgroundService(this), new TestTriggerService(this));
    Iif (init) {
      this.testInterface = init(this);
    } else {
      this.testInterface = null;
    }
  }
 
  async initModule(): Promise<void> {
    this.setClient(this.testInterface?.client || new TestClient(this));
    this.setPresenter(this.testInterface?.presenter || new TestPresenter(this));
    this.debug('FirstTHIS');
    this.setCache(this.testInterface?.cache || new InMemCache(this, 10000));
    const db = new TestPrefab(this.testInterface?.db || new InMemDB(this));
    db.setEntityCache(this.testInterface?.cache !== null);
    this.setDb(db);
    await this.initBundleModule();
    await this.getKernel().triggerEvent('load');
  }
 
  async initBundleModule(): Promise<void> {
    this.debug('triggerBundleInit');
  }
}