fixed all tests

This commit is contained in:
Boki 2025-06-26 17:30:13 -04:00
parent 08f713d98b
commit bd26ecf3bc
11 changed files with 457 additions and 794 deletions

View file

@ -5,16 +5,7 @@ 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();
expect(shutdownExports.SHUTDOWN_DEFAULTS).toBeDefined();
});
it('should export Shutdown class', () => {
@ -24,43 +15,13 @@ describe('Shutdown Package Exports', () => {
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');
expect(typeof shutdownExports.SHUTDOWN_DEFAULTS).toBe('object');
});
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();
it('should have correct SHUTDOWN_DEFAULTS values', () => {
expect(shutdownExports.SHUTDOWN_DEFAULTS).toHaveProperty('TIMEOUT');
expect(shutdownExports.SHUTDOWN_DEFAULTS).toHaveProperty('HIGH_PRIORITY');
expect(shutdownExports.SHUTDOWN_DEFAULTS).toHaveProperty('MEDIUM_PRIORITY');
expect(shutdownExports.SHUTDOWN_DEFAULTS).toHaveProperty('LOW_PRIORITY');
});
});
});