7
7
import { AbortError , DefaultHttpClient , HttpClient , HttpRequest , HttpResponse , HttpTransportType , HubConnectionBuilder , IHttpConnectionOptions , JsonHubProtocol , NullLogger } from "@microsoft/signalr" ;
8
8
import { MessagePackHubProtocol } from "@microsoft/signalr-protocol-msgpack" ;
9
9
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" ;
11
11
import "./LogBannerReporter" ;
12
12
import { TestLogger } from "./TestLogger" ;
13
13
@@ -17,6 +17,7 @@ import * as RX from "rxjs";
17
17
18
18
const TESTHUBENDPOINT_URL = ENDPOINT_BASE_URL + "/testhub" ;
19
19
const TESTHUBENDPOINT_HTTPS_URL = ENDPOINT_BASE_HTTPS_URL ? ( ENDPOINT_BASE_HTTPS_URL + "/testhub" ) : undefined ;
20
+ const HTTPORHTTPS_TESTHUBENDPOINT_URL = shouldRunHttpsTests ? TESTHUBENDPOINT_HTTPS_URL : TESTHUBENDPOINT_URL ;
20
21
21
22
const TESTHUB_NOWEBSOCKETS_ENDPOINT_URL = ENDPOINT_BASE_URL + "/testhub-nowebsockets" ;
22
23
const TESTHUB_REDIRECT_ENDPOINT_URL = ENDPOINT_BASE_URL + "/redirect?numRedirects=0&baseUrl=" + ENDPOINT_BASE_URL ;
@@ -25,17 +26,6 @@ const commonOptions: IHttpConnectionOptions = {
25
26
logMessageContent : true ,
26
27
} ;
27
28
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
-
39
29
function getConnectionBuilder ( transportType ?: HttpTransportType , url ?: string , options ?: IHttpConnectionOptions ) : HubConnectionBuilder {
40
30
let actualOptions : IHttpConnectionOptions = options || { } ;
41
31
if ( transportType ) {
@@ -690,7 +680,7 @@ describe("hubConnection", () => {
690
680
}
691
681
692
682
it ( "preserves cookies between requests" , async ( done ) => {
693
- const hubConnection = getConnectionBuilder ( transportType ) . build ( ) ;
683
+ const hubConnection = getConnectionBuilder ( transportType , HTTPORHTTPS_TESTHUBENDPOINT_URL ) . build ( ) ;
694
684
await hubConnection . start ( ) ;
695
685
const cookieValue = await hubConnection . invoke < string > ( "GetCookie" , "testCookie" ) ;
696
686
const cookieValue2 = await hubConnection . invoke < string > ( "GetCookie" , "testCookie2" ) ;
@@ -701,7 +691,7 @@ describe("hubConnection", () => {
701
691
} ) ;
702
692
703
693
it ( "expired cookies are not preserved" , async ( done ) => {
704
- const hubConnection = getConnectionBuilder ( transportType ) . build ( ) ;
694
+ const hubConnection = getConnectionBuilder ( transportType , HTTPORHTTPS_TESTHUBENDPOINT_URL ) . build ( ) ;
705
695
await hubConnection . start ( ) ;
706
696
const cookieValue = await hubConnection . invoke < string > ( "GetCookie" , "expiredCookie" ) ;
707
697
expect ( cookieValue ) . toBeNull ( ) ;
0 commit comments