@@ -2,7 +2,6 @@ import * as fs from 'fs';
22import { fileURLToPath } from 'url' ;
33import { test } from 'uvu' ;
44import * as assert from 'uvu/assert' ;
5- import fetch from 'node-fetch' ;
65
76const build = fileURLToPath ( new URL ( '../build' , import . meta. url ) ) ;
87
@@ -12,12 +11,6 @@ const read = (file) => fs.readFileSync(`${build}/${file}`, 'utf-8');
1211/** @param {string } file */
1312const readNoUtf = ( file ) => fs . readFileSync ( `${ build } /${ file } ` ) ;
1413
15- async function bufferFromUrl ( url ) {
16- const response = await fetch ( url ) ;
17- const blob = await response . blob ( ) ;
18- return Buffer . from ( await blob . arrayBuffer ( ) ) ;
19- }
20-
2114test ( 'prerenders /' , ( ) => {
2215 const content = read ( 'index.html' ) ;
2316 assert . ok ( content . includes ( '<h1>hello</h1>' ) ) ;
@@ -152,28 +145,17 @@ test('targets the data-sveltekit-hydrate parent node', () => {
152145} ) ;
153146
154147test ( 'check binary data not corrupted - jpg' , async ( ) => {
155- const url = 'https://upload.wikimedia.org/wikipedia/commons/b/b2/JPEG_compression_Example.jpg' ;
156-
157- const originalBuffer = await bufferFromUrl ( url ) ;
158-
159- const content = readNoUtf ( 'fetch-image/image.jpg' ) ;
160- const newBuffer = Buffer . from ( content , 'binary' ) ;
161-
162- const compare = Buffer . compare ( originalBuffer , newBuffer ) ;
148+ const newFile = readNoUtf ( 'fetch-image/image.jpg' ) ;
149+ const orgFile = readNoUtf ( 'image.jpg' ) ;
150+ const compare = Buffer . compare ( newFile , orgFile ) ;
163151
164152 assert . ok ( compare === 0 ) ;
165153} ) ;
166154
167155test ( 'check binary files not corrupted - png' , async ( ) => {
168- const url =
169- 'https://repository-images.githubusercontent.com/354583933/72c58c80-9727-11eb-98b2-f352fded32b9' ;
170-
171- const originalBuffer = await bufferFromUrl ( url ) ;
172-
173- const content = readNoUtf ( 'fetch-image/image.png' ) ;
174- const newBuffer = Buffer . from ( content , 'binary' ) ;
175-
176- const compare = Buffer . compare ( originalBuffer , newBuffer ) ;
156+ const newFile = readNoUtf ( 'fetch-image/image.png' ) ;
157+ const orgFile = readNoUtf ( 'image.png' ) ;
158+ const compare = Buffer . compare ( newFile , orgFile ) ;
177159
178160 assert . ok ( compare === 0 ) ;
179161} ) ;
0 commit comments