File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1+ import { fixUint8Array } from "./uint8array" ;
2+
3+ describe ( "fixUint8Array" , ( ) => {
4+ it ( "works for Uint8Array<ArrayBuffer>" , ( ) => {
5+ const input : Uint8Array < ArrayBuffer > = Uint8Array . of ( 1 , 2 , 255 ) ;
6+ const fixed = fixUint8Array ( input ) ;
7+ expect ( fixed ) . toEqual ( input ) ;
8+ expect ( fixed . buffer ) . toBeInstanceOf ( ArrayBuffer ) ;
9+ expect ( fixed . buffer ) . toBe ( input . buffer ) ; // no copy must be performed in this case
10+ } ) ;
11+
12+ it ( "works for Uint8Array<SharedArrayBuffer>" , ( ) => {
13+ const sharedBuffer = new SharedArrayBuffer ( 8 ) ;
14+ const input : Uint8Array < SharedArrayBuffer > = new Uint8Array ( sharedBuffer ) ;
15+ const fixed = fixUint8Array ( input ) ;
16+ expect ( fixed ) . toEqual ( input ) ;
17+ expect ( fixed . buffer ) . toBeInstanceOf ( ArrayBuffer ) ;
18+ } ) ;
19+ } ) ;
You can’t perform that action at this time.
0 commit comments