59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
var node_events = require('node:events');
|
|
var tap = require('tap');
|
|
var nodeOsc = require('node-osc');
|
|
|
|
function flaky() {
|
|
return process.release.lts === 'Dubnium' && process.platform === 'win32';
|
|
}
|
|
|
|
function skip(t) {
|
|
t.skip(`flaky ~ ${t.name}`);
|
|
t.end();
|
|
}
|
|
|
|
tap.test('osc: argument message no callback', async (t) => {
|
|
if (flaky()) return skip(t);
|
|
|
|
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
await node_events.once(oscServer, 'listening');
|
|
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
|
|
t.plan(1);
|
|
|
|
t.teardown(() => {
|
|
oscServer.close();
|
|
client.close();
|
|
});
|
|
|
|
oscServer.on('message', (msg) => {
|
|
t.same(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload');
|
|
});
|
|
|
|
client.send('/test', 1, 2, 'testing');
|
|
});
|
|
|
|
tap.test('osc: client with callback and message as arguments', async (t) => {
|
|
if (flaky()) return skip(t);
|
|
|
|
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
await node_events.once(oscServer, 'listening');
|
|
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
|
|
t.plan(2);
|
|
|
|
t.teardown(() => {
|
|
oscServer.close();
|
|
client.close();
|
|
});
|
|
|
|
oscServer.on('message', (msg) => {
|
|
t.same(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload');
|
|
});
|
|
|
|
client.send('/test', 1, 2, 'testing', (err) => {
|
|
t.error(err, 'there should be no error');
|
|
});
|
|
});
|