Skip to content

Commit adeb063

Browse files
committed
fix(network): enhance isValidPort method to check for number type
fix(tests): ensure emitter is disposed after each test and improve cleanup
1 parent 6f646c8 commit adeb063

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/domains/network/network-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class NetworkUtils {
150150
* @since v1.0.0
151151
*/
152152
isValidPort(port: unknown): boolean {
153-
return numbersGuard.isInteger(port) && port >= 0 && port <= 65535;
153+
return numbersGuard.isNumber(port) && numbersGuard.isInteger(port) && port >= 0 && port <= 65535;
154154
}
155155
}
156156

src/tools/queues/docs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export interface BaseQueueTask<T = any, K extends Record<string, any> = Record<s
5050
* Optional callback executed when the task's action resolves successfully.
5151
* Receives the resolved value from `action`.
5252
*/
53-
onResolve?: (result?: T, metadata?: DeepReadonly<K>) => any | Promise<any>;
53+
onResolve?: (result: T, metadata?: DeepReadonly<K>) => any | Promise<any>;
5454

5555
/**
5656
* Optional callback executed if the task's action rejects with an error.
5757
* Receives the error thrown by `action`.
5858
*/
59-
onReject?: (error?: Error) => any | Promise<any>;
59+
onReject?: (error: Error) => any | Promise<any>;
6060

6161
/** Optional callback executed when the task completes, regardless of success or failure. */
6262
onDone?: () => any | Promise<any>;

tests/atomix/tools/eventEmitter.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ describe('EventEmitter', () => {
44
let emitter: EventEmitter;
55

66
beforeEach(() => {
7+
if (emitter) { emitter.dispose() }
78
emitter = new EventEmitter();
89
emitter.maxHandlers = 100; // disable limit during most tests
910
jest.useFakeTimers();
@@ -13,6 +14,10 @@ describe('EventEmitter', () => {
1314
jest.useRealTimers();
1415
});
1516

17+
afterAll(() => {
18+
emitter.dispose();
19+
});
20+
1621
it('should register and call a normal handler', async () => {
1722
const fn = jest.fn();
1823
emitter.on('test', fn);
@@ -47,7 +52,7 @@ describe('EventEmitter', () => {
4752
});
4853

4954
emitter.on('async', () => callOrder.push('B'));
50-
55+
5156
await emitter.emit('async');
5257
await new Promise(res => setTimeout(res, 100));
5358
expect(callOrder).toEqual(['A', 'B']);

0 commit comments

Comments
 (0)