UNPKG

open-epsilon

Version:

empty-epsilon / open-sound-control bidirectional proxy

53 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const osc_1 = require("osc"); const osc_udp_driver_1 = require("../src/osc-udp-driver"); const chai_1 = require("chai"); const sinon_1 = require("sinon"); function delay(timeout) { return new Promise(r => setTimeout(r, timeout)); } const NETWORK_GRACE = 30; describe('OscUdpDriver (real network test)', () => { const MSG = { address: '/foo/bar', args: [{ type: 'f', value: 5.677999973297119 }] }; const sent = sinon_1.spy(); const received = sinon_1.spy(); let oscDriver = new osc_udp_driver_1.OscUdpDriver({ remotePort: 56668, localPort: 56667, localAddress: '0.0.0.0', metadata: true }); let udpPort = new osc_1.UDPPort({ remotePort: 56667, localPort: 56668, remoteAddress: '127.0.0.1', localAddress: '0.0.0.0', metadata: true }); udpPort.on('message', sent); oscDriver.inbox.subscribe(received); before(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { udpPort.open(); oscDriver.open(); yield delay(1); })); after(() => { udpPort.close(); oscDriver.close(); }); it('can send messages', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { oscDriver.outbox.next(MSG); yield delay(NETWORK_GRACE); chai_1.expect(sent).to.have.callCount(1); chai_1.expect(sent).to.have.been.calledWith(MSG); })); it('can receive messages', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { udpPort.send(MSG); yield delay(NETWORK_GRACE); chai_1.expect(received).to.have.callCount(1); chai_1.expect(received).to.have.been.calledWith(MSG); })); }); //# sourceMappingURL=osc-driver.spec.js.map