77import { AbortError , DefaultHttpClient , HttpClient , HttpRequest , HttpResponse , HttpTransportType , HubConnectionBuilder , IHttpConnectionOptions , JsonHubProtocol , NullLogger } from "@microsoft/signalr" ;
88import { MessagePackHubProtocol } from "@microsoft/signalr-protocol-msgpack" ;
99
10- import { eachTransport , eachTransportAndProtocol , ENDPOINT_BASE_HTTPS_URL , ENDPOINT_BASE_URL } from "./Common" ;
10+ import { eachTransport , eachTransportAndProtocol , ENDPOINT_BASE_HTTPS_URL , ENDPOINT_BASE_URL , shouldRunHttpsTests } from "./Common" ;
1111import "./LogBannerReporter" ;
1212import { TestLogger } from "./TestLogger" ;
1313
@@ -17,6 +17,7 @@ import * as RX from "rxjs";
1717
1818const TESTHUBENDPOINT_URL = ENDPOINT_BASE_URL + "/testhub" ;
1919const TESTHUBENDPOINT_HTTPS_URL = ENDPOINT_BASE_HTTPS_URL ? ( ENDPOINT_BASE_HTTPS_URL + "/testhub" ) : undefined ;
20+ const HTTPORHTTPS_TESTHUBENDPOINT_URL = shouldRunHttpsTests ? TESTHUBENDPOINT_HTTPS_URL : TESTHUBENDPOINT_URL ;
2021
2122const TESTHUB_NOWEBSOCKETS_ENDPOINT_URL = ENDPOINT_BASE_URL + "/testhub-nowebsockets" ;
2223const TESTHUB_REDIRECT_ENDPOINT_URL = ENDPOINT_BASE_URL + "/redirect?numRedirects=0&baseUrl=" + ENDPOINT_BASE_URL ;
@@ -25,17 +26,6 @@ const commonOptions: IHttpConnectionOptions = {
2526 logMessageContent : true ,
2627} ;
2728
28- // Run test in Node or Chrome, but not on macOS
29- const shouldRunHttpsTests =
30- // Need to have an HTTPS URL
31- ! ! TESTHUBENDPOINT_HTTPS_URL &&
32-
33- // Run on Node, unless macOS
34- ( process && process . platform !== "darwin" ) &&
35-
36- // Only run under Chrome browser
37- ( typeof navigator === "undefined" || navigator . userAgent . search ( "Chrome" ) !== - 1 ) ;
38-
3929function getConnectionBuilder ( transportType ?: HttpTransportType , url ?: string , options ?: IHttpConnectionOptions ) : HubConnectionBuilder {
4030 let actualOptions : IHttpConnectionOptions = options || { } ;
4131 if ( transportType ) {
@@ -690,7 +680,7 @@ describe("hubConnection", () => {
690680 }
691681
692682 it ( "preserves cookies between requests" , async ( done ) => {
693- const hubConnection = getConnectionBuilder ( transportType ) . build ( ) ;
683+ const hubConnection = getConnectionBuilder ( transportType , HTTPORHTTPS_TESTHUBENDPOINT_URL ) . build ( ) ;
694684 await hubConnection . start ( ) ;
695685 const cookieValue = await hubConnection . invoke < string > ( "GetCookie" , "testCookie" ) ;
696686 const cookieValue2 = await hubConnection . invoke < string > ( "GetCookie" , "testCookie2" ) ;
@@ -701,7 +691,7 @@ describe("hubConnection", () => {
701691 } ) ;
702692
703693 it ( "expired cookies are not preserved" , async ( done ) => {
704- const hubConnection = getConnectionBuilder ( transportType ) . build ( ) ;
694+ const hubConnection = getConnectionBuilder ( transportType , HTTPORHTTPS_TESTHUBENDPOINT_URL ) . build ( ) ;
705695 await hubConnection . start ( ) ;
706696 const cookieValue = await hubConnection . invoke < string > ( "GetCookie" , "expiredCookie" ) ;
707697 expect ( cookieValue ) . toBeNull ( ) ;
0 commit comments