Skip to content

Commit

Permalink
added tests, prepublish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fed135 committed Mar 27, 2020
1 parent 13011e5 commit bb4243f
Show file tree
Hide file tree
Showing 29 changed files with 228 additions and 867 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,18 @@ packages/tcp/bin
packages/udp/bin
packages/ws/bin
packages/webrtc/bin

# publish-only files
packages/kalm/LICENSE
packages/ipc/LICENSE
packages/tcp/LICENSE
packages/udp/LICENSE
packages/ws/LICENSE
packages/webrtc/LICENSE

packages/kalm/CHANGELOG.md
packages/ipc/CHANGELOG.md
packages/tcp/CHANGELOG.md
packages/udp/CHANGELOG.md
packages/ws/CHANGELOG.md
packages/webrtc/CHANGELOG.md
127 changes: 0 additions & 127 deletions packages/ipc/CHANGELOG.md

This file was deleted.

13 changes: 0 additions & 13 deletions packages/ipc/LICENSE

This file was deleted.

3 changes: 2 additions & 1 deletion packages/ipc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "../../scripts/build.sh ipc",
"clean": "../../scripts/cleanup.sh",
"test": "jest ./tests"
"test": "jest ./tests",
"prepublish": "cp ../../LICENSE ./LICENSE && cp ../../CHANGELOG.md ./CHANGELOG.md"
},
"funding": {
"type": "Open Collective",
Expand Down
6 changes: 3 additions & 3 deletions packages/ipc/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IPCSocket extends net.Socket {
}
}

export function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {}): KalmTransport {
function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {}): KalmTransport {
return function socket(params: ClientConfig, emitter: NodeJS.EventEmitter): Socket {
let listener: net.Server;

Expand All @@ -25,8 +25,8 @@ export function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCCon

function remote(handle: IPCSocket): Remote {
return {
host: handle._server._pipeName,
port: handle._handle.fd,
host: handle && handle._server && handle._server._pipeName || null,
port: handle && handle._handle && handle._handle.fd || null,
};
}

Expand Down
37 changes: 36 additions & 1 deletion packages/ipc/tests/unit/ipc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
import { EventEmitter } from 'events';
import * as ipc from '../../src/ipc';

describe('IPC transport', () => {
it('TODO', () => { expect(ipc).not.toBeUndefined(); });
it('basic setup', () => {
expect(typeof ipc.default).toBe('function');
const transport = ipc.default();
expect(typeof transport).toBe('function');
const socket = transport({}, new EventEmitter());

expect(socket).toHaveProperty('bind', expect.any(Function));
expect(socket).toHaveProperty('connect', expect.any(Function));
expect(socket).toHaveProperty('disconnect', expect.any(Function));
expect(socket).toHaveProperty('remote', expect.any(Function));
expect(socket).toHaveProperty('stop', expect.any(Function));
expect(socket).toHaveProperty('send', expect.any(Function));
});

describe('Given an empty handle reference and no configs', () => {
const transport = ipc.default();
const socket = transport({}, new EventEmitter());

describe('when fetching remote', () => {
it('should return null values', () => {
expect(socket.remote()).toEqual({ host: null, port: null });
});
});
});

describe('Given a handle reference and no configs', () => {
const transport = ipc.default();
const socket = transport({}, new EventEmitter());

describe('when fetching remote', () => {
it('should return handle\'s values', () => {
expect(socket.remote({ _server: { _pipeName: '/foo' }, _handle: { fd: 12345 } })).toEqual({ host: '/foo', port: 12345 });
});
});
});
});
127 changes: 0 additions & 127 deletions packages/kalm/CHANGELOG.md

This file was deleted.

13 changes: 0 additions & 13 deletions packages/kalm/LICENSE

This file was deleted.

3 changes: 2 additions & 1 deletion packages/kalm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "../../scripts/build.sh kalm",
"clean": "../../scripts/cleanup.sh",
"test": "jest ./tests"
"test": "jest ./tests",
"prepublish": "cp ../../LICENSE ./LICENSE && cp ../../CHANGELOG.md ./CHANGELOG.md"
},
"funding": {
"type": "Open Collective",
Expand Down
Loading

0 comments on commit bb4243f

Please sign in to comment.