@@ -35,13 +35,43 @@ describe('U8aFixed', (): void => {
3535 new Uint8Array ( [ 0x02 , 0x03 , 0x00 , 0x00 ] )
3636 ) ;
3737 } ) ;
38+
39+ it ( 'constructs when passed Uint8Array is >= length' , ( ) : void => {
40+ expect (
41+ new ( U8aFixed . with ( 32 ) ) ( registry , new Uint8Array ( [ 0x00 , 0x01 , 0x02 , 0x03 ] ) ) . toU8a ( )
42+ ) . toEqual (
43+ new Uint8Array ( [ 0x00 , 0x01 , 0x02 , 0x03 ] )
44+ ) ;
45+ expect (
46+ new ( U8aFixed . with ( 32 ) ) ( registry , new Uint8Array ( [ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 ] ) ) . toU8a ( )
47+ ) . toEqual (
48+ new Uint8Array ( [ 0x00 , 0x01 , 0x02 , 0x03 ] )
49+ ) ;
50+ } ) ;
51+
52+ it ( 'constructs when passed string is === length' , ( ) : void => {
53+ expect (
54+ new ( U8aFixed . with ( 32 ) ) ( registry , '1234' ) . toU8a ( )
55+ ) . toEqual (
56+ new Uint8Array ( [ 49 , 50 , 51 , 52 ] )
57+ ) ;
58+ } ) ;
59+
60+ it ( 'fails construction when passed string is > length' , ( ) : void => {
61+ expect (
62+ ( ) => new ( U8aFixed . with ( 32 ) ) ( registry , '0x000102030405' ) . toU8a ( )
63+ ) . toThrow ( / E x p e c t e d i n p u t w i t h 4 b y t e s / ) ;
64+ expect (
65+ ( ) => new ( U8aFixed . with ( 256 ) ) ( registry , '1363HWTPzDrzAQ6ChFiMU6mP4b6jmQid2ae55JQcKtZnpLGv' )
66+ ) . toThrow ( / E x p e c t e d i n p u t w i t h 3 2 b y t e s / ) ;
67+ } ) ;
3868 } ) ;
3969
4070 describe ( 'utils' , ( ) : void => {
4171 let u8a : U8aFixed ;
4272
4373 beforeEach ( ( ) : void => {
44- u8a = new U8aFixed ( registry , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] , 32 ) ;
74+ u8a = new U8aFixed ( registry , [ 1 , 2 , 3 , 4 ] , 32 ) ;
4575 } ) ;
4676
4777 it ( 'limits the length' , ( ) : void => {
0 commit comments