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();
done();
} catch (e) {
fail(e);
}
});
});
export function getHttpClients(): HttpClient[] {
const httpClients: HttpClient[] = [];
if (typeof XMLHttpRequest !== "undefined") {
httpClients.push(new XhrHttpClient(TestLogger.instance));
}
if (typeof fetch !== "undefined") {
httpClients.push(new FetchHttpClient(TestLogger.instance));
}
if (Platform.isNode) {
httpClients.push(new NodeHttpClient(TestLogger.instance));
}
return httpClients;
}