fix(tests): Remove redundant manual topic handlers from tests and rely on server built-in pub/sub
This commit is contained in:
14
changelog.md
14
changelog.md
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-08-29 - 2.2.1 - fix(tests)
|
||||
Remove redundant manual topic handlers from tests and rely on server built-in pub/sub
|
||||
|
||||
- Removed manual server.onMessage('__subscribe__') and server.onMessage('__publish__') handlers from test/test.ts
|
||||
- Tests now rely on the server's built-in publish/subscribe behavior: clients publish directly and subscribers receive messages
|
||||
- Test code simplified without changing public API or runtime behavior
|
||||
|
||||
## 2025-08-29 - 2.2.0 - feat(ipcclient)
|
||||
Add clientOnly mode to prevent clients from auto-starting servers and improve registration/reconnect behavior
|
||||
|
||||
@@ -92,3 +99,10 @@ Initial release and a series of patch fixes to core components.
|
||||
|
||||
- 1.0.1: initial release.
|
||||
- 1.0.2 → 1.0.7: a sequence of small core fixes and maintenance updates (repeated "fix(core): update" commits).
|
||||
## 2025-08-29 - 2.1.4 - feat(transports)
|
||||
Add client-only mode to prevent unintended server auto-start in Unix/NamedPipe transports; safer probing
|
||||
|
||||
- Add `clientOnly?: boolean` to transport options; when true (or `SMARTIPC_CLIENT_ONLY=1`), a client will fail fast on `ECONNREFUSED`/`ENOENT` instead of auto-starting a server.
|
||||
- Update `SmartIpc.waitForServer()` to probe with `clientOnly: true` to avoid races during readiness checks.
|
||||
- Extend tests to cover option and env override; update core test to use unique socket path and auto-cleanup.
|
||||
- Docs: add README section for client-only mode.
|
||||
|
11
test/test.ts
11
test/test.ts
@@ -161,17 +161,6 @@ tap.test('should handle pub/sub pattern', async () => {
|
||||
messageReceived.resolve();
|
||||
});
|
||||
|
||||
// Server handles the subscription
|
||||
server.onMessage('__subscribe__', async (payload, clientId) => {
|
||||
expect(payload.topic).toEqual('news');
|
||||
});
|
||||
|
||||
// Server handles publishing
|
||||
server.onMessage('__publish__', async (payload, clientId) => {
|
||||
// Broadcast to all subscribers of the topic
|
||||
await server.broadcast(`topic:${payload.topic}`, payload.payload);
|
||||
});
|
||||
|
||||
// Client 2 publishes to the topic
|
||||
await client2.publish('news', { headline: 'Breaking news!' });
|
||||
|
||||
|
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartipc',
|
||||
version: '2.2.0',
|
||||
version: '2.2.1',
|
||||
description: 'A library for node inter process communication, providing an easy-to-use API for IPC.'
|
||||
}
|
||||
|
Reference in New Issue
Block a user