@aptpod/iscp-ts
Version:
iSCP 2.0 client library for TypeScript
87 lines • 2.61 kB
JavaScript
import { DownstreamCloseRequest, DownstreamCloseRequestExtensionFields } from '../../message';
const WIRE_DOWNSTREAM_CLOSE_REQUEST = new DownstreamCloseRequest({
requestId: 123,
streamId: '01020304-0506-4708-890a-111213141516',
extensionFields: undefined,
});
const PROTO_DOWNSTREAM_CLOSE_REQUEST = {
requestId: 123,
streamId: new Uint8Array([
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x47, 0x08, 0x89, 0x0a, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
]),
extensionFields: undefined,
};
export const withoutExtensionFields = {
toWire: () => {
return new DownstreamCloseRequest({
...WIRE_DOWNSTREAM_CLOSE_REQUEST,
});
},
toProto: () => {
return {
message: {
oneofKind: 'downstreamCloseRequest',
downstreamCloseRequest: {
...PROTO_DOWNSTREAM_CLOSE_REQUEST,
},
},
};
},
};
export const withExtensionFields = {
toWire: () => {
return new DownstreamCloseRequest({
...WIRE_DOWNSTREAM_CLOSE_REQUEST,
extensionFields: new DownstreamCloseRequestExtensionFields(),
});
},
toProto: () => {
return {
message: {
oneofKind: 'downstreamCloseRequest',
downstreamCloseRequest: {
...PROTO_DOWNSTREAM_CLOSE_REQUEST,
extensionFields: {},
},
},
};
},
};
export const invalidWire = {
streamId: {
toWire: () => {
return new DownstreamCloseRequest({
...WIRE_DOWNSTREAM_CLOSE_REQUEST,
streamId: '00010203',
});
},
toErrorClass: () => {
return TypeError;
},
toError: () => {
return new (invalidWire.streamId.toErrorClass())('Invalid UUID');
},
},
};
export const invalidProto = {
streamId: {
toProto: () => {
return {
message: {
oneofKind: 'downstreamCloseRequest',
downstreamCloseRequest: {
...PROTO_DOWNSTREAM_CLOSE_REQUEST,
streamId: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
},
},
};
},
toErrorClass: () => {
return TypeError;
},
toError: () => {
return new (invalidProto.streamId.toErrorClass())('Stringified UUID is invalid');
},
},
};
//# sourceMappingURL=downstream-close-request.js.map