Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("sets the user agent header", async (done) => {
const hubConnection = getConnectionBuilder(t, TESTHUBENDPOINT_URL)
.withHubProtocol(new JsonHubProtocol())
.build();
try {
await hubConnection.start();
// Check to see that the Content-Type header is set the expected value
const [name, value] = getUserAgentHeader();
const headerValue = await hubConnection.invoke("GetHeader", name);
if ((t === HttpTransportType.ServerSentEvents || t === HttpTransportType.WebSockets) && !Platform.isNode) {
expect(headerValue).toBeNull();
} else {
expect(headerValue).toEqual(value);
}
await hubConnection.stop();
export function eachTransportAndProtocol(action: (transport: HttpTransportType, protocol: IHubProtocol) => void) {
const protocols: IHubProtocol[] = [new JsonHubProtocol()];
// Run messagepack tests in Node and Browsers that support binary content (indicated by the presence of responseType property)
if (typeof XMLHttpRequest === "undefined" || typeof new XMLHttpRequest().responseType === "string") {
// Because of TypeScript stuff, we can't get "ambient" or "global" declarations to work with the MessagePackHubProtocol module
// This is only a limitation of the .d.ts file.
// Everything works fine in the module
protocols.push(new MessagePackHubProtocol());
}
getHttpTransportTypes().forEach((t) => {
return protocols.forEach((p) => {
if (t !== HttpTransportType.ServerSentEvents || !(p instanceof MessagePackHubProtocol)) {
return action(t, p);
}
});
});
}