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 { BinaryMessageFormat } from "../src/BinaryMessageFormat"
4+ import { BinaryMessageFormat } from "../src/BinaryMessageFormat" ;
55
66describe ( "Binary Message Formatter" , ( ) => {
77 ( [
8- [ [ ] , < Uint8Array [ ] > [ ] ] ,
9- [ [ 0x00 ] , < Uint8Array [ ] > [ new Uint8Array ( [ ] ) ] ] ,
10- [ [ 0x01 , 0xff ] , < Uint8Array [ ] > [ new Uint8Array ( [ 0xff ] ) ] ] ,
8+ [ [ ] , [ ] as Uint8Array [ ] ] ,
9+ [ [ 0x00 ] , [ new Uint8Array ( [ ] ) ] as Uint8Array [ ] ] ,
10+ [ [ 0x01 , 0xff ] , [ new Uint8Array ( [ 0xff ] ) ] as Uint8Array [ ] ] ,
1111 [ [ 0x01 , 0xff ,
12- 0x01 , 0x7f ] , < Uint8Array [ ] > [ new Uint8Array ( [ 0xff ] ) , new Uint8Array ( [ 0x7f ] ) ] ] ,
13- ] as [ number [ ] , Uint8Array [ ] ] [ ] ) . forEach ( ( [ payload , expected_messages ] ) => {
12+ 0x01 , 0x7f ] , [ new Uint8Array ( [ 0xff ] ) , new Uint8Array ( [ 0x7f ] ) ] as Uint8Array [ ] ] ,
13+ ] as Array < [ number [ ] , Uint8Array [ ] ] > ) . forEach ( ( [ payload , expectedMessages ] ) => {
1414 it ( `should parse '${ payload } ' correctly` , ( ) => {
15- let messages = BinaryMessageFormat . parse ( new Uint8Array ( payload ) . buffer ) ;
16- expect ( messages ) . toEqual ( expected_messages ) ;
17- } )
15+ const messages = BinaryMessageFormat . parse ( new Uint8Array ( payload ) . buffer ) ;
16+ expect ( messages ) . toEqual ( expectedMessages ) ;
17+ } ) ;
1818 } ) ;
1919
2020 ( [
@@ -26,34 +26,34 @@ describe("Binary Message Formatter", () => {
2626 [ [ 0x80 , 0x80 , 0x80 , 0x80 , 0x08 ] , new Error ( "Messages bigger than 2GB are not supported." ) ] ,
2727 [ [ 0x80 , 0x80 , 0x80 , 0x80 , 0x80 ] , new Error ( "Messages bigger than 2GB are not supported." ) ] ,
2828 [ [ 0x02 , 0x00 ] , new Error ( "Incomplete message." ) ] ,
29- [ [ 0xff , 0xff , 0xff , 0xff , 0x07 ] , new Error ( "Incomplete message." ) ]
30- ] as [ number [ ] , Error ] [ ] ) . forEach ( ( [ payload , expected_error ] ) => {
29+ [ [ 0xff , 0xff , 0xff , 0xff , 0x07 ] , new Error ( "Incomplete message." ) ] ,
30+ ] as Array < [ number [ ] , Error ] > ) . forEach ( ( [ payload , expectedError ] ) => {
3131 it ( `should fail to parse '${ payload } '` , ( ) => {
32- expect ( ( ) => BinaryMessageFormat . parse ( new Uint8Array ( payload ) . buffer ) ) . toThrow ( expected_error ) ;
33- } )
32+ expect ( ( ) => BinaryMessageFormat . parse ( new Uint8Array ( payload ) . buffer ) ) . toThrow ( expectedError ) ;
33+ } ) ;
3434 } ) ;
3535
3636 ( [
3737 [ [ ] , [ 0x00 ] ] ,
3838 [ [ 0x20 ] , [ 0x01 , 0x20 ] ] ,
39- ] as [ number [ ] , number [ ] ] [ ] ) . forEach ( ( [ input , expected_payload ] ) => {
39+ ] as Array < [ number [ ] , number [ ] ] > ) . forEach ( ( [ input , expectedPayload ] ) => {
4040 it ( `should write '${ input } '` , ( ) => {
41- let actual = new Uint8Array ( BinaryMessageFormat . write ( new Uint8Array ( input ) ) ) ;
42- let expected = new Uint8Array ( expected_payload ) ;
41+ const actual = new Uint8Array ( BinaryMessageFormat . write ( new Uint8Array ( input ) ) ) ;
42+ const expected = new Uint8Array ( expectedPayload ) ;
4343 expect ( actual ) . toEqual ( expected ) ;
44- } )
44+ } ) ;
4545 } ) ;
4646
47- ( [ 0x0000 , 0x0001 , 0x007f , 0x0080 , 0x3fff , 0x4000 , 0xc0de ] as number [ ] ) . forEach ( size => {
47+ ( [ 0x0000 , 0x0001 , 0x007f , 0x0080 , 0x3fff , 0x4000 , 0xc0de ] as number [ ] ) . forEach ( ( size ) => {
4848 it ( `messages should be roundtrippable (message size: '${ size } ')` , ( ) => {
4949 const message = [ ] ;
5050 for ( let i = 0 ; i < size ; i ++ ) {
5151 message . push ( i & 0xff ) ;
5252 }
5353
54- var payload = new Uint8Array ( message ) ;
54+ const payload = new Uint8Array ( message ) ;
5555 expect ( payload ) . toEqual ( BinaryMessageFormat . parse ( BinaryMessageFormat . write ( payload ) ) [ 0 ] ) ;
56- } )
56+ } ) ;
5757 } ) ;
5858
59- } ) ;
59+ } ) ;
0 commit comments