Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TestXVIZSnapshotGLB = d;
}
});
writer.writeMessage(0, TestXVIZSnapshot);
// Load the data in XVIZData and verify the format
const TestCases = [
{
data: TestXVIZSnapshot,
description: 'XVIZ Object',
format: XVIZ_FORMAT.OBJECT
},
{
data: TestXVIZSnapshotString,
description: 'XVIZ String',
format: XVIZ_FORMAT.JSON_STRING
},
{
data: ` ${TestXVIZSnapshotString} `,
description: 'XVIZ String with whitespace head and tail',
format: XVIZ_FORMAT.JSON_STRING
},
{
data: TestXVIZSnapshotBuffer,
description: 'XVIZ String Buffer',
format: XVIZ_FORMAT.JSON_BUFFER
},
{
data: TestXVIZSnapshotGLB,
description: 'XVIZ Binary Buffer',
format: XVIZ_FORMAT.BINARY_GLB
},
// Load the data in XVIZData and verify the format
const TestCases = [
{
data: TestXVIZSnapshot,
description: 'XVIZ Object',
format: XVIZ_FORMAT.OBJECT
},
{
data: TestXVIZSnapshotString,
description: 'XVIZ String',
format: XVIZ_FORMAT.JSON_STRING
},
{
data: ` ${TestXVIZSnapshotString} `,
description: 'XVIZ String with whitespace head and tail',
format: XVIZ_FORMAT.JSON_STRING
},
{
data: TestXVIZSnapshotBuffer,
description: 'XVIZ String Buffer',
format: XVIZ_FORMAT.JSON_BUFFER
},
{
data: TestXVIZSnapshotGLB,
description: 'XVIZ Binary Buffer',
format: XVIZ_FORMAT.BINARY_GLB
},
{
data: Buffer.from(TestXVIZSnapshotBuffer),
description: 'XVIZ String NodeBuffer',
format: XVIZ_FORMAT.JSON_BUFFER,
nodeOnly: true
tape('XVIZFormatWriter#full matrix', t => {
const dataSources = [
TestXVIZSnapshot,
TestXVIZSnapshotString,
TestXVIZSnapshotBuffer,
TestXVIZSnapshotGLB
];
for (const source of dataSources) {
const xvizObj = new XVIZData(source);
for (const format of [
XVIZ_FORMAT.BINARY_GLB,
XVIZ_FORMAT.JSON_BUFFER,
XVIZ_FORMAT.JSON_STRING
]) {
const sink = new MemorySourceSink();
t.comment(`-- TestCase ${xvizObj.format} to ${format}`);
// Convert the data to the requested format
// data is state_update and this will default to a message sequence of 0
const formatWriter = new XVIZFormatWriter(sink, {format});
formatWriter.writeMessage(0, xvizObj);
// We don't really care about the key as each writer will have
// different identifier, (eg: 1-frame.json vs 1.frame.glb)
for (const [key, val] of sink.entries()) {
// Cover Arrays, Strings, ArrayBuffers
t.ok(val.byteLength || val.length, `${key} has formatted data`);
const testSessionMaker = (socket, req) => {
const context = new XVIZSessionContext();
const provider = new TestProvider(makeXVIZData(100, 110));
const middleware = new XVIZServerMiddlewareStack();
const stack = [
new XVIZProviderRequestHandler(context, provider, middleware, {logger}),
new XVIZWebsocketSender(context, socket, {format: XVIZ_FORMAT.JSON_STRING})
];
middleware.set(stack);
return new TestSession(socket, middleware);
};