test: add tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { Downloader } from "../dist/index.mjs";
|
||||
|
||||
const resolveTargetDir = () => mkdtempSync(join(tmpdir(), "test-"));
|
||||
|
||||
const TEST_DATA = {
|
||||
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-win.zip": "haxe.exe",
|
||||
"https://home.shmyga.ru/public/sdk/haxe/haxe-4.2.5-linux64.tar.gz": "haxe",
|
||||
"https://home.shmyga.ru/public/test.txt": "test.txt",
|
||||
};
|
||||
|
||||
for (const [url, file] of Object.entries(TEST_DATA)) {
|
||||
test(`Test download: ${url}`, async () => {
|
||||
const target = resolveTargetDir();
|
||||
await Downloader.download(url, target);
|
||||
assert(existsSync(join(target, file)));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user