@@ -45,9 +45,9 @@ describe('ByteRangeContext', () => {
45
45
const array = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ]
46
46
const uint8arrayRangeTests = [
47
47
// full ranges:
48
- { type : 'Uint8Array' , range : 'bytes=0-11 ' , contentRange : 'bytes 0-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
49
- { type : 'Uint8Array' , range : 'bytes=-11' , contentRange : 'bytes 1-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
50
- { type : 'Uint8Array' , range : 'bytes=0-' , contentRange : 'bytes 0-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
48
+ { type : 'Uint8Array' , range : 'bytes=0-10 ' , contentRange : 'bytes 0-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
49
+ { type : 'Uint8Array' , range : 'bytes=-11' , contentRange : 'bytes 0-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
50
+ { type : 'Uint8Array' , range : 'bytes=0-' , contentRange : 'bytes 0-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array ) } ,
51
51
52
52
// partial ranges:
53
53
{ type : 'Uint8Array' , range : 'bytes=0-1' , contentRange : 'bytes 0-1/11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 1 , 2 ] ) } ,
@@ -60,13 +60,13 @@ describe('ByteRangeContext', () => {
60
60
{ type : 'Uint8Array' , range : 'bytes=0-8' , contentRange : 'bytes 0-8/11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ) } ,
61
61
{ type : 'Uint8Array' , range : 'bytes=0-9' , contentRange : 'bytes 0-9/11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ) } ,
62
62
{ type : 'Uint8Array' , range : 'bytes=0-10' , contentRange : 'bytes 0-10/11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ] ) } ,
63
- { type : 'Uint8Array' , range : 'bytes=1-' , contentRange : 'bytes 1-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ] ) } ,
64
- { type : 'Uint8Array' , range : 'bytes=2-' , contentRange : 'bytes 2-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ] ) } ,
65
- { type : 'Uint8Array' , range : 'bytes=-2' , contentRange : 'bytes 10-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array . slice ( - 2 ) ) } ,
63
+ { type : 'Uint8Array' , range : 'bytes=1-' , contentRange : 'bytes 1-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ] ) } ,
64
+ { type : 'Uint8Array' , range : 'bytes=2-' , contentRange : 'bytes 2-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( [ 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ] ) } ,
65
+ { type : 'Uint8Array' , range : 'bytes=-2' , contentRange : 'bytes 9-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array . slice ( - 2 ) ) } ,
66
66
67
67
// single byte ranges:
68
68
{ type : 'Uint8Array' , range : 'bytes=1-1' , contentRange : 'bytes 1-1/11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array . slice ( 1 , 2 ) ) } ,
69
- { type : 'Uint8Array' , range : 'bytes=-1' , contentRange : 'bytes 11-11 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array . slice ( - 1 ) ) }
69
+ { type : 'Uint8Array' , range : 'bytes=-1' , contentRange : 'bytes 10-10 /11' , body : new Uint8Array ( array ) , expected : new Uint8Array ( array . slice ( - 1 ) ) }
70
70
71
71
]
72
72
const validRanges = [
@@ -138,12 +138,11 @@ describe('ByteRangeContext', () => {
138
138
} )
139
139
const stat = await fs . stat ( cid )
140
140
context . setFileSize ( stat . fileSize )
141
-
142
141
context . setBody ( await getBodyStream ( context . offset , context . length ) )
143
142
const response = new Response ( context . getBody ( ) )
144
143
const bodyResult = await response . arrayBuffer ( )
145
- expect ( new Uint8Array ( bodyResult ) ) . to . deep . equal ( expected )
146
144
expect ( context . contentRangeHeaderValue ) . to . equal ( contentRange )
145
+ expect ( new Uint8Array ( bodyResult ) ) . to . deep . equal ( expected )
147
146
} )
148
147
} )
149
148
} )
0 commit comments