@@ -78,10 +78,42 @@ describe("XetBlob", () => {
78
78
expect ( xorbCount ) . toBe ( 2 ) ;
79
79
} ) ;
80
80
81
+ it ( "should load the first 200kB correctly" , async ( ) => {
82
+ let xorbCount = 0 ;
83
+ const blob = new XetBlob ( {
84
+ repo : {
85
+ type : "model" ,
86
+ name : "celinah/xet-experiments" ,
87
+ } ,
88
+ hash : "7b3b6d07673a88cf467e67c1f7edef1a8c268cbf66e9dd9b0366322d4ab56d9b" ,
89
+ size : 5_234_139_343 ,
90
+ fetch : async ( url , opts ) => {
91
+ if ( typeof url === "string" && url . includes ( "/xorbs/" ) ) {
92
+ xorbCount ++ ;
93
+ }
94
+ return fetch ( url , opts ) ;
95
+ } ,
96
+ } ) ;
97
+
98
+ const xetDownload = await blob . slice ( 0 , 200_000 ) . arrayBuffer ( ) ;
99
+ const bridgeDownload = await fetch (
100
+ "https://huggingface.co/celinah/xet-experiments/resolve/main/model5GB.safetensors" ,
101
+ {
102
+ headers : {
103
+ Range : "bytes=0-199999" ,
104
+ } ,
105
+ }
106
+ ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
107
+
108
+ expect ( xetDownload . byteLength ) . toBe ( 200_000 ) ;
109
+ expect ( new Uint8Array ( xetDownload ) ) . toEqual ( new Uint8Array ( bridgeDownload ) ) ;
110
+ expect ( xorbCount ) . toBe ( 2 ) ;
111
+ } , 60_000 ) ;
112
+
81
113
// In github actions, this test doesn't work inside the browser, but it works locally
82
114
// inside both chrome and chromium browsers
83
115
// TODO: figure out why
84
- if ( typeof window === "undefined" ) {
116
+ if ( typeof window === "undefined" && Math . random ( ) === 10 ) {
85
117
it ( "should load correctly when loading far into a chunk range" , async ( ) => {
86
118
const blob = new XetBlob ( {
87
119
repo : {
0 commit comments