added cli-covarage tool and fixed more tests
This commit is contained in:
parent
b63e58784c
commit
b845a8eade
57 changed files with 11917 additions and 295 deletions
66
libs/core/shutdown/test/index.test.ts
Normal file
66
libs/core/shutdown/test/index.test.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { describe, it, expect } from 'bun:test';
|
||||
import * as shutdownExports from '../src';
|
||||
import { Shutdown } from '../src';
|
||||
|
||||
describe('Shutdown Package Exports', () => {
|
||||
it('should export all main functions', () => {
|
||||
expect(shutdownExports.onShutdown).toBeDefined();
|
||||
expect(shutdownExports.onShutdownHigh).toBeDefined();
|
||||
expect(shutdownExports.onShutdownMedium).toBeDefined();
|
||||
expect(shutdownExports.onShutdownLow).toBeDefined();
|
||||
expect(shutdownExports.setShutdownTimeout).toBeDefined();
|
||||
expect(shutdownExports.isShuttingDown).toBeDefined();
|
||||
expect(shutdownExports.isShutdownSignalReceived).toBeDefined();
|
||||
expect(shutdownExports.getShutdownCallbackCount).toBeDefined();
|
||||
expect(shutdownExports.initiateShutdown).toBeDefined();
|
||||
expect(shutdownExports.shutdownAndExit).toBeDefined();
|
||||
expect(shutdownExports.resetShutdown).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export Shutdown class', () => {
|
||||
expect(shutdownExports.Shutdown).toBeDefined();
|
||||
expect(shutdownExports.Shutdown).toBe(Shutdown);
|
||||
});
|
||||
|
||||
it('should export correct function types', () => {
|
||||
expect(typeof shutdownExports.onShutdown).toBe('function');
|
||||
expect(typeof shutdownExports.onShutdownHigh).toBe('function');
|
||||
expect(typeof shutdownExports.onShutdownMedium).toBe('function');
|
||||
expect(typeof shutdownExports.onShutdownLow).toBe('function');
|
||||
expect(typeof shutdownExports.setShutdownTimeout).toBe('function');
|
||||
expect(typeof shutdownExports.isShuttingDown).toBe('function');
|
||||
expect(typeof shutdownExports.isShutdownSignalReceived).toBe('function');
|
||||
expect(typeof shutdownExports.getShutdownCallbackCount).toBe('function');
|
||||
expect(typeof shutdownExports.initiateShutdown).toBe('function');
|
||||
expect(typeof shutdownExports.shutdownAndExit).toBe('function');
|
||||
expect(typeof shutdownExports.resetShutdown).toBe('function');
|
||||
});
|
||||
|
||||
it('should export type definitions', () => {
|
||||
// Type tests - these compile-time checks ensure types are exported
|
||||
type TestShutdownCallback = shutdownExports.ShutdownCallback;
|
||||
type TestShutdownOptions = shutdownExports.ShutdownOptions;
|
||||
type TestShutdownResult = shutdownExports.ShutdownResult;
|
||||
type TestPrioritizedShutdownCallback = shutdownExports.PrioritizedShutdownCallback;
|
||||
|
||||
// Runtime check that types can be used
|
||||
const testCallback: TestShutdownCallback = async () => {};
|
||||
const testOptions: TestShutdownOptions = { timeout: 5000, autoRegister: false };
|
||||
const testResult: TestShutdownResult = {
|
||||
success: true,
|
||||
callbacksExecuted: 1,
|
||||
callbacksFailed: 0,
|
||||
duration: 100,
|
||||
};
|
||||
const testPrioritized: TestPrioritizedShutdownCallback = {
|
||||
callback: testCallback,
|
||||
priority: 50,
|
||||
name: 'test',
|
||||
};
|
||||
|
||||
expect(testCallback).toBeDefined();
|
||||
expect(testOptions).toBeDefined();
|
||||
expect(testResult).toBeDefined();
|
||||
expect(testPrioritized).toBeDefined();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue