node-simple-ipc
Version:
A Node.Js module for local Inter Process Communication
66 lines • 2.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const validation_1 = require("./validation");
describe('assertValidIpcName()', function () {
it('should not throw an error on a valid IPC name.', function () {
expect(() => (0, validation_1.assertValidIpcName)('hello')).not.toThrow();
});
it('should throw an error on an empty IPC name.', function () {
expect(() => (0, validation_1.assertValidIpcName)('')).toThrow();
});
});
describe('assertValidIpcHandler()', function () {
it('should not throw an error on a valid IPC handler.', function () {
expect(() => (0, validation_1.assertValidIpcHandler)(() => 1)).not.toThrow();
});
it('should throw an error on an invalid IPC handler.', function () {
expect(() => (0, validation_1.assertValidIpcHandler)(1)).toThrow();
});
});
describe('isIpcInput()', function () {
it('should return true on a valid input object.', function () {
expect((0, validation_1.isIpcInput)({
type: "I" /* Input */,
name: 'hello',
correlationId: '123',
})).toEqual(true);
});
it('should return false on an invalid input object.', function () {
expect((0, validation_1.isIpcInput)(undefined)).toEqual(false);
expect((0, validation_1.isIpcInput)({
hello: 'world',
})).toEqual(false);
});
});
describe('isIpcOutput()', function () {
it('should return true on a valid output object.', function () {
expect((0, validation_1.isIpcOutput)({
type: "O" /* Output */,
name: 'hello',
correlationId: '321',
})).toEqual(true);
});
it('should return false on an invalid output object.', function () {
expect((0, validation_1.isIpcOutput)(undefined)).toEqual(false);
expect((0, validation_1.isIpcOutput)({
hello: 'world',
})).toEqual(false);
});
});
describe('isIpcEvent()', function () {
it('should return true on a valid event object.', function () {
expect((0, validation_1.isIpcEvent)({
type: "E" /* Event */,
name: 'hello',
data: '321',
})).toEqual(true);
});
it('should return false on an invalid event object.', function () {
expect((0, validation_1.isIpcEvent)(undefined)).toEqual(false);
expect((0, validation_1.isIpcEvent)({
name: 'world',
type: 'event',
})).toEqual(false);
});
});
//# sourceMappingURL=validation.spec.js.map