mirror of
https://github.com/jwetzell/osc-js.git
synced 2026-09-01 20:28:59 +00:00
add real basic bundle tests
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
const { deepEqual } = require('assert');
|
||||||
|
const { describe, it } = require('node:test');
|
||||||
|
const osc = require('../dist/index');
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
description: 'simple contents single message',
|
||||||
|
expected: {
|
||||||
|
timeTag: [32, 0],
|
||||||
|
contents: [{ address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] }],
|
||||||
|
},
|
||||||
|
bundle: Buffer.concat([
|
||||||
|
Buffer.from('#bundle', 'ascii'),
|
||||||
|
Buffer.from([0x00]),
|
||||||
|
Buffer.from([0, 0, 0, 32, 0, 0, 0, 0]),
|
||||||
|
Buffer.from('00000020', 'hex'),
|
||||||
|
Buffer.from('2f6f7363696c6c61746f722f342f6672657175656e6379002c66000043dc0000', 'hex'),
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('OSC Bundle Decoding', () => {
|
||||||
|
tests.forEach((bundleTest) => {
|
||||||
|
it(bundleTest.description, () => {
|
||||||
|
const encoded = osc.bundleFromBuffer(bundleTest.bundle);
|
||||||
|
deepEqual(encoded, bundleTest.expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
const { deepEqual, throws } = require('assert');
|
||||||
|
const { describe, it } = require('node:test');
|
||||||
|
const osc = require('../dist/index');
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
description: 'simple contents single message',
|
||||||
|
bundle: { timeTag: [32, 0], contents: [{ address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] }] },
|
||||||
|
expected: Buffer.concat([
|
||||||
|
Buffer.from('#bundle', 'ascii'),
|
||||||
|
Buffer.from([0x00]),
|
||||||
|
Buffer.from([0, 0, 0, 32, 0, 0, 0, 0]),
|
||||||
|
Buffer.from('00000020', 'hex'),
|
||||||
|
Buffer.from('2f6f7363696c6c61746f722f342f6672657175656e6379002c66000043dc0000', 'hex'),
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('OSC Bundle Encoding', () => {
|
||||||
|
tests.forEach((bundleTest) => {
|
||||||
|
it(bundleTest.description, () => {
|
||||||
|
const encoded = osc.bundleToBuffer(bundleTest.bundle);
|
||||||
|
deepEqual(encoded, bundleTest.expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user