Skip to content

Commit 6891b82

Browse files
committed
fix: test - browser download file
1 parent 245dea4 commit 6891b82

8 files changed

Lines changed: 857 additions & 762 deletions

File tree

package-lock.json

Lines changed: 844 additions & 743 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
"@types/node": "^20.4.9",
107107
"@typescript-eslint/eslint-plugin": "^6.3.0",
108108
"@typescript-eslint/parser": "^6.3.0",
109-
"@vitest/ui": "^1.6.0",
110109
"dotenv": "^16.3.1",
111110
"eslint": "^8.46.0",
112111
"eslint-plugin-import": "^2.28.0",
@@ -122,8 +121,8 @@
122121
"typedoc-material-theme": "^1.1.0",
123122
"typedoc-plugin-missing-exports": "^3.0.0",
124123
"typescript": "^5.5.3",
125-
"vitest": "^1.6.0",
126-
"xmlhttprequest-ssl": "^2.1.1"
124+
"vitest": "^4.0.18",
125+
"xmlhttprequest-ssl": "^4.0.0"
127126
},
128127
"optionalDependencies": {
129128
"@reflink/reflink": "^0.1.16"

test/browser.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ globalThis.XMLHttpRequest = await import("xmlhttprequest-ssl").then(m => m.XMLHt
1010

1111
describe("Browser Fetch API", () => {
1212
test.concurrent("Download file browser - memory", async (context) => {
13+
1314
const downloader = await downloadFileBrowser({
1415
url: BIG_FILE
1516
});
1617

1718
await downloader.download();
1819
const hash = hashBuffer(downloader.writeStream.result);
1920
context.expect(hash)
20-
.toMatchInlineSnapshot("\"9ae3ff19ee04fc02e9c60ce34e42858d16b46eeb88634d2035693c1ae9dbcbc9\"");
21+
.toMatchInlineSnapshot(`"0e1a20347e130a168a5c555826915a1302e3fae467b85db6aae53c243c2b0a26"`);
2122
});
2223

2324
test.concurrent("Download file browser", async (context) => {
@@ -37,11 +38,11 @@ describe("Browser Fetch API", () => {
3738

3839
await downloader.download();
3940
context.expect(hashBuffer(buffer))
40-
.toMatchInlineSnapshot("\"9ae3ff19ee04fc02e9c60ce34e42858d16b46eeb88634d2035693c1ae9dbcbc9\"");
41+
.toMatchInlineSnapshot(`"0e1a20347e130a168a5c555826915a1302e3fae467b85db6aae53c243c2b0a26"`);
4142
context.expect(lastWrite)
4243
.toBe(downloader.file.totalSize);
4344
});
44-
}, {timeout: 1000 * 60 * 3});
45+
});
4546

4647
describe("Browser Fetch memory", () => {
4748
test.sequential("Download file for tests", async (context) => {
@@ -50,7 +51,7 @@ describe("Browser Fetch memory", () => {
5051
const buffer = Buffer.from(await fs.readFile(response));
5152
const hash = hashBuffer(buffer);
5253
context.expect(hash)
53-
.toMatchInlineSnapshot("\"9ae3ff19ee04fc02e9c60ce34e42858d16b46eeb88634d2035693c1ae9dbcbc9\"");
54+
.toMatchInlineSnapshot(`"0e1a20347e130a168a5c555826915a1302e3fae467b85db6aae53c243c2b0a26"`);
5455
});
5556

5657
test.sequential("Download file browser - memory (xhr)", async (context) => {
@@ -91,4 +92,4 @@ describe("Browser Fetch memory", () => {
9192
context.expect(diff)
9293
.toBe(-1);
9394
});
94-
}, {timeout: 1000 * 60 * 3});
95+
});

test/copy-file.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ describe("File Copy", async () => {
4949
context.expect(copiedFileHash)
5050
.toBe(originalFileHash);
5151
});
52-
}, {timeout: 1000 * 60 * 3});
52+
});

test/download.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ describe("File Download", () => {
6060
context.expect(totalBytesWritten)
6161
.toBe(file.totalSize);
6262
});
63-
}, {timeout: 1000 * 60 * 3});
63+
});

test/fetchDownloadInfo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ describe("Fetch download info", () => {
2525
context.expect(downloader.file.totalSize > 0)
2626
.toBeTruthy();
2727
});
28-
}, {timeout: 0});
28+
});

test/utils/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const BIG_FILE = "https://upload.wikimedia.org/wikipedia/commons/9/9e/1_dubrovnik_pano_-_edit1.jpg"; // 40mb
1+
export const BIG_FILE = "https://huggingface.co/datasets/ChaoticNeutrals/Creative_Writing-ShareGPT/resolve/main/Creative_Writing-ShareGPT.jsonl?download=true"; // 27.5mb

vitest.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ export default defineConfig({
44
test: {
55
pool: "threads",
66
maxWorkers: 1,
7-
minWorkers: 1,
8-
poolOptions: {
9-
threads: {
10-
minThreads: 1,
11-
maxThreads: 1
12-
}
13-
}
7+
testTimeout: 1000 * 60 * 3
148
}
159
});

0 commit comments

Comments
 (0)