11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4- import { HttpTransportType , IHttpConnectionOptions , LogLevel , TransferFormat } from "@aspnet/signalr" ;
4+ // This code uses a lot of `.then` instead of `await` and TSLint doesn't like it.
5+ // tslint:disable:no-floating-promises
6+
7+ import { HttpTransportType , IHttpConnectionOptions , TransferFormat } from "@aspnet/signalr" ;
58import { eachTransport , ECHOENDPOINT_URL } from "./Common" ;
69import { TestLogger } from "./TestLogger" ;
710
@@ -23,15 +26,13 @@ describe("connection", () => {
2326 ...commonOptions ,
2427 } ) ;
2528
26- let received = "" ;
27- connection . onreceive = ( data ) => {
28- received += data ;
29+ connection . onreceive = async ( data : any ) => {
2930 if ( data === message ) {
3031 connection . stop ( ) ;
3132 }
3233 } ;
3334
34- connection . onclose = ( error ) => {
35+ connection . onclose = ( error : any ) => {
3536 expect ( error ) . toBeUndefined ( ) ;
3637 done ( ) ;
3738 } ;
@@ -55,22 +56,20 @@ describe("connection", () => {
5556 transport : transportType ,
5657 } ) ;
5758
58- let received = "" ;
59- connection . onreceive = ( data ) => {
60- received += data ;
59+ connection . onreceive = ( data : any ) => {
6160 if ( data === message ) {
6261 connection . stop ( ) ;
6362 }
6463 } ;
6564
66- connection . onclose = ( error ) => {
65+ connection . onclose = ( error : any ) => {
6766 expect ( error ) . toBeUndefined ( ) ;
6867 done ( ) ;
6968 } ;
7069
7170 connection . start ( TransferFormat . Text ) . then ( ( ) => {
7271 connection . send ( message ) ;
73- } ) . catch ( ( e ) => {
72+ } ) . catch ( ( e : any ) => {
7473 fail ( e ) ;
7574 done ( ) ;
7675 } ) ;
@@ -85,15 +84,17 @@ describe("connection", () => {
8584 transport : transportType ,
8685 } ) ;
8786
88- connection . onreceive = ( data ) => {
87+ connection . onreceive = ( data : any ) => {
8988 if ( data === message ) {
9089 connection . stop ( ) ;
9190 }
9291 } ;
9392
93+ // @ts -ignore: We don't use the error parameter intentionally.
9494 connection . onclose = ( error ) => {
9595 // Search the logs for the message content
9696 expect ( TestLogger . instance . currentLog . messages . length ) . toBeGreaterThan ( 0 ) ;
97+ // @ts -ignore: We don't use the _ or __ parameters intentionally.
9798 for ( const [ _ , __ , logMessage ] of TestLogger . instance . currentLog . messages ) {
9899 expect ( logMessage ) . not . toContain ( message ) ;
99100 }
@@ -118,16 +119,18 @@ describe("connection", () => {
118119 transport : transportType ,
119120 } ) ;
120121
121- connection . onreceive = ( data ) => {
122+ connection . onreceive = ( data : any ) => {
122123 if ( data === message ) {
123124 connection . stop ( ) ;
124125 }
125126 } ;
126127
128+ // @ts -ignore: We don't use the error parameter intentionally.
127129 connection . onclose = ( error ) => {
128130 // Search the logs for the message content
129131 let matches = 0 ;
130132 expect ( TestLogger . instance . currentLog . messages . length ) . toBeGreaterThan ( 0 ) ;
133+ // @ts -ignore: We don't use the _ or __ parameters intentionally.
131134 for ( const [ _ , __ , logMessage ] of TestLogger . instance . currentLog . messages ) {
132135 if ( logMessage . indexOf ( message ) !== - 1 ) {
133136 matches += 1 ;
@@ -141,7 +144,7 @@ describe("connection", () => {
141144
142145 connection . start ( TransferFormat . Text ) . then ( ( ) => {
143146 connection . send ( message ) ;
144- } ) . catch ( ( e ) => {
147+ } ) . catch ( ( e : any ) => {
145148 fail ( e ) ;
146149 done ( ) ;
147150 } ) ;
0 commit comments