All files / src/dev/lib start.ts

100% Statements 19/19
50% Branches 2/4
100% Functions 7/7
100% Lines 19/19

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            1x 1x   1x 1x 1x     1x 1x 1x 1x 1x   1x 1x     1x 1x 1x   1x 1x               1x 4x            
import { describe, test, expect } from 'vitest';
import fs from 'fs';
import TestContext from '../TestContext';
import { StoreGlobal } from '../../modules';
 
export default function jestStart() {
  describe('start', () => {
    const [kernel, , modLen] = TestContext.getEntity();
 
    describe('Clean start', () => {
      test('preload', async () => {
        expect(kernel.getState()).toBe('init');
      });
 
      test('start kernel', async () => {
        const result = await kernel.start();
        expect(result).toBe(true);
        expect(kernel.getModCount()).toBe(modLen ?? 2);
        expect(kernel.getState()).toBe('running');
      });
      test('kernel info', async () => {
        expect(kernel.getModCount(true)).toBe(
          modLen === null ? 2 + 2 : modLen + 2,
        );
        expect(kernel.getServiceList(true).length).toBeGreaterThan(0);
        expect(kernel.getActionList(true).length).toBeGreaterThan(0);
        expect(kernel.getState()).toBe('running');
      });
      test('kernel folder', async () => {
        const folderList = kernel
          .getConfigStore()
          .getBulk(
            [StoreGlobal.GLOBAL_PATH_HOME],
            [StoreGlobal.GLOBAL_PATH_DATA],
            [StoreGlobal.GLOBAL_PATH_DB],
            [StoreGlobal.GLOBAL_PATH_TEMP],
          );
        for (const folder of folderList) {
          expect(fs.existsSync(folder)).toBeTruthy();
        }
      });
    });
  });
}