1515 * limitations under the License.
1616 ***********************************************************************/
1717
18- var WebSocketClient = require ( '../../lib/WebSocketClient' ) ;
19- var wsVersion = require ( '../../lib/websocket' ) . version ;
20- var querystring = require ( 'querystring' ) ;
18+ const WebSocketClient = require ( '../../lib/WebSocketClient' ) ;
19+ const wsVersion = require ( '../../lib/websocket' ) . version ;
20+ const querystring = require ( 'querystring' ) ;
2121
22- var args = { /* defaults */
22+ const args = { /* defaults */
2323 secure : false ,
2424 port : '9000' ,
2525 host : 'localhost'
2626} ;
2727
2828/* Parse command line options */
29- var pattern = / ^ - - ( .* ?) (?: = ( .* ) ) ? $ / ;
30- process . argv . forEach ( function ( value ) {
31- var match = pattern . exec ( value ) ;
29+ const pattern = / ^ - - ( .* ?) (?: = ( .* ) ) ? $ / ;
30+ process . argv . forEach ( ( value ) => {
31+ const match = pattern . exec ( value ) ;
3232 if ( match ) {
3333 args [ match [ 1 ] ] = match [ 2 ] ? match [ 2 ] : true ;
3434 }
@@ -43,19 +43,19 @@ console.log('');
4343
4444console . log ( 'Starting test run.' ) ;
4545
46- getCaseCount ( function ( caseCount ) {
47- var currentCase = 1 ;
46+ getCaseCount ( ( caseCount ) => {
47+ let currentCase = 1 ;
4848 runNextTestCase ( ) ;
4949
5050 function runNextTestCase ( ) {
51- runTestCase ( currentCase ++ , caseCount , function ( ) {
51+ runTestCase ( currentCase ++ , caseCount , ( ) => {
5252 if ( currentCase <= caseCount ) {
5353 process . nextTick ( runNextTestCase ) ;
5454 }
5555 else {
56- process . nextTick ( function ( ) {
56+ process . nextTick ( ( ) => {
5757 console . log ( 'Test suite complete, generating report.' ) ;
58- updateReport ( function ( ) {
58+ updateReport ( ( ) => {
5959 console . log ( 'Report generated.' ) ;
6060 } ) ;
6161 } ) ;
@@ -66,27 +66,27 @@ getCaseCount(function(caseCount) {
6666
6767
6868function runTestCase ( caseIndex , caseCount , callback ) {
69- console . log ( ' Running test ' + caseIndex + ' of ' + caseCount ) ;
70- var echoClient = new WebSocketClient ( {
69+ console . log ( ` Running test ${ caseIndex } of ${ caseCount } ` ) ;
70+ const echoClient = new WebSocketClient ( {
7171 maxReceivedFrameSize : 64 * 1024 * 1024 , // 64MiB
7272 maxReceivedMessageSize : 64 * 1024 * 1024 , // 64MiB
7373 fragmentOutgoingMessages : false ,
7474 keepalive : false ,
7575 disableNagleAlgorithm : false
7676 } ) ;
7777
78- echoClient . on ( 'connectFailed' , function ( error ) {
79- console . log ( ' Connect Error: ' + error . toString ( ) ) ;
78+ echoClient . on ( 'connectFailed' , ( error ) => {
79+ console . log ( ` Connect Error: ${ error . toString ( ) } ` ) ;
8080 } ) ;
8181
82- echoClient . on ( 'connect' , function ( connection ) {
83- connection . on ( 'error' , function ( error ) {
84- console . log ( ' Connection Error: ' + error . toString ( ) ) ;
82+ echoClient . on ( 'connect' , ( connection ) => {
83+ connection . on ( 'error' , ( error ) => {
84+ console . log ( ` Connection Error: ${ error . toString ( ) } ` ) ;
8585 } ) ;
86- connection . on ( 'close' , function ( ) {
86+ connection . on ( 'close' , ( ) => {
8787 callback ( ) ;
8888 } ) ;
89- connection . on ( 'message' , function ( message ) {
89+ connection . on ( 'message' , ( message ) => {
9090 if ( message . type === 'utf8' ) {
9191 connection . sendUTF ( message . utf8Data ) ;
9292 }
@@ -96,40 +96,40 @@ function runTestCase(caseIndex, caseCount, callback) {
9696 } ) ;
9797 } ) ;
9898
99- var qs = querystring . stringify ( {
99+ const qs = querystring . stringify ( {
100100 case : caseIndex ,
101- agent : ' WebSocket-Node Client v' + wsVersion
101+ agent : ` WebSocket-Node Client v${ wsVersion } `
102102 } ) ;
103- echoClient . connect ( ' ws://' + args . host + ':' + args . port + ' /runCase?' + qs , [ ] ) ;
103+ echoClient . connect ( ` ws://${ args . host } : ${ args . port } /runCase?${ qs } ` , [ ] ) ;
104104}
105105
106106function getCaseCount ( callback ) {
107- var client = new WebSocketClient ( ) ;
108- var caseCount = NaN ;
109- client . on ( 'connect' , function ( connection ) {
110- connection . on ( 'close' , function ( ) {
107+ const client = new WebSocketClient ( ) ;
108+ let caseCount = NaN ;
109+ client . on ( 'connect' , ( connection ) => {
110+ connection . on ( 'close' , ( ) => {
111111 callback ( caseCount ) ;
112112 } ) ;
113- connection . on ( 'message' , function ( message ) {
113+ connection . on ( 'message' , ( message ) => {
114114 if ( message . type === 'utf8' ) {
115- console . log ( ' Got case count: ' + message . utf8Data ) ;
115+ console . log ( ` Got case count: ${ message . utf8Data } ` ) ;
116116 caseCount = parseInt ( message . utf8Data , 10 ) ;
117117 }
118118 else if ( message . type === 'binary' ) {
119119 throw new Error ( 'Unexpected binary message when retrieving case count' ) ;
120120 }
121121 } ) ;
122122 } ) ;
123- client . connect ( ' ws://' + args . host + ':' + args . port + ' /getCaseCount' , [ ] ) ;
123+ client . connect ( ` ws://${ args . host } : ${ args . port } /getCaseCount` , [ ] ) ;
124124}
125125
126126function updateReport ( callback ) {
127- var client = new WebSocketClient ( ) ;
128- var qs = querystring . stringify ( {
129- agent : ' WebSocket-Node Client v' + wsVersion
127+ const client = new WebSocketClient ( ) ;
128+ const qs = querystring . stringify ( {
129+ agent : ` WebSocket-Node Client v${ wsVersion } `
130130 } ) ;
131- client . on ( 'connect' , function ( connection ) {
131+ client . on ( 'connect' , ( connection ) => {
132132 connection . on ( 'close' , callback ) ;
133133 } ) ;
134- client . connect ( ' ws://localhost:9000/updateReports?' + qs ) ;
134+ client . connect ( ` ws://localhost:9000/updateReports?${ qs } ` ) ;
135135}
0 commit comments