@@ -1864,14 +1864,27 @@ test("fetch method", (t) => {
1864
1864
reactNative : { textStreaming : true } ,
1865
1865
} ) ;
1866
1866
const clone = res . clone ( ) ;
1867
- const stream = await clone . body ;
1868
- const text = new TextDecoder ( ) . decode ( await drainStream ( stream ) ) ;
1867
+
1868
+ const resStream = await res . body ;
1869
+ const cloneStream = await clone . body ;
1870
+ const resText = new TextDecoder ( ) . decode (
1871
+ await drainStream ( resStream )
1872
+ ) ;
1873
+ const cloneText = new TextDecoder ( ) . decode (
1874
+ await drainStream ( cloneStream )
1875
+ ) ;
1869
1876
1870
1877
t . ok (
1871
- stream instanceof ReadableStream ,
1878
+ resStream instanceof ReadableStream ,
1872
1879
"Response implements streaming body"
1873
1880
) ;
1874
- t . eq ( text , "Hello world!" ) ;
1881
+ t . eq ( resText , "Hello world!" ) ;
1882
+
1883
+ t . ok (
1884
+ cloneStream instanceof ReadableStream ,
1885
+ "Response implements streaming body"
1886
+ ) ;
1887
+ t . eq ( cloneText , "Hello world!" ) ;
1875
1888
} ) ;
1876
1889
1877
1890
t . test ( "cloning blob response" , async ( t ) => {
@@ -1882,8 +1895,11 @@ test("fetch method", (t) => {
1882
1895
} ,
1883
1896
} ) ;
1884
1897
const clone = res . clone ( ) ;
1885
- const json = await clone . json ( ) ;
1886
- t . eq ( json . headers . accept , "application/json" ) ;
1898
+ const resJson = res . json ( ) ;
1899
+ const cloneJson = await clone . json ( ) ;
1900
+
1901
+ t . eq ( resJson . headers . accept , "application/json" ) ;
1902
+ t . eq ( cloneJson . headers . accept , "application/json" ) ;
1887
1903
} ) ;
1888
1904
1889
1905
t . test ( "cloning array buffer response" , async ( t ) => {
@@ -1894,15 +1910,28 @@ test("fetch method", (t) => {
1894
1910
} ,
1895
1911
} ) ;
1896
1912
const clone = res . clone ( ) ;
1897
- const buf = await clone . arrayBuffer ( ) ;
1913
+ const resBuf = await res . arrayBuffer ( ) ;
1914
+ const cloneBuf = await clone . arrayBuffer ( ) ;
1898
1915
1899
- t . ok ( buf instanceof ArrayBuffer , "buf is an ArrayBuffer instance" ) ;
1900
- t . eq ( buf . byteLength , 256 , "buf.byteLength is correct" ) ;
1916
+ t . ok (
1917
+ resBuf instanceof ArrayBuffer ,
1918
+ "buf is an ArrayBuffer instance"
1919
+ ) ;
1920
+ t . eq ( resBuf . byteLength , 256 , "buf.byteLength is correct" ) ;
1921
+
1922
+ t . ok (
1923
+ cloneBuf instanceof ArrayBuffer ,
1924
+ "buf is an ArrayBuffer instance"
1925
+ ) ;
1926
+ t . eq ( cloneBuf . byteLength , 256 , "buf.byteLength is correct" ) ;
1901
1927
1902
1928
const expected = Array . from ( { length : 256 } , ( _ , i ) => i ) ;
1903
- const actual = Array . from ( new Uint8Array ( buf ) ) ;
1904
1929
1905
- t . eq ( actual , expected ) ;
1930
+ const resActual = Array . from ( new Uint8Array ( resBuf ) ) ;
1931
+ const cloneActual = Array . from ( new Uint8Array ( cloneBuf ) ) ;
1932
+
1933
+ t . eq ( resActual , expected ) ;
1934
+ t . eq ( cloneActual , expected ) ;
1906
1935
} ) ;
1907
1936
} ) ;
1908
1937
} ) ;
0 commit comments