update nodejs tests

This commit is contained in:
Caelan
2024-10-06 20:29:58 -06:00
parent d91478fff6
commit 4fe71521f6
4 changed files with 100 additions and 93 deletions

3
.gitignore vendored
View File

@@ -3,7 +3,6 @@ target/
_docyml/
target
index.node
**/node_modules
**/.DS_Store
npm-debug.log*
@@ -11,7 +10,7 @@ lib
cargo.log
cross.log
*.tgz
*.node
#################
## Eclipse

View File

@@ -8,13 +8,20 @@ function makeCopies(input) {
// this is obviously not correct for a "production" bundle, but it is used for testing
// creating a "node" module at all of the expected production locations allows us to test
// webpack require resolution and native module bundling etc.
fs.mkdirSync("./lib/native");
if (!fs.existsSync("./lib/native")) fs.mkdirSync("./lib/native");
if (!fs.existsSync("./src/native")) fs.mkdirSync("./src/native");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_arm64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_arm64_gnu.node");
}
if (platform == "win32") {

View File

@@ -4,17 +4,21 @@ import {
UpdateOptions,
VelopackApp,
VelopackLocatorConfig,
setVelopackLogger,
} from "../src";
import path from "path";
import {tempd3, fixture, updateExe, shortDelay} from "./helper";
function testInit() {
VelopackApp.build().run();
setVelopackLogger((level, msg) => {
console.log(level, msg);
});
}
test("UpdateManager detects local update", () => {
return tempd3(async (tmpDir, packagesDir, rootDir) => {
VelopackApp.build()
.setLogger((level, msg) => {
console.log(level, msg);
})
.run();
testInit();
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
@@ -48,11 +52,7 @@ test("UpdateManager detects local update", () => {
test("UpdateManager downloads full update", () => {
return tempd3(async (feedDir, packagesDir, rootDir) => {
VelopackApp.build()
.setLogger((level, msg) => {
console.log(level, msg);
})
.run();
testInit();
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
@@ -83,7 +83,8 @@ test("UpdateManager downloads full update", () => {
console.log(
`about to download update from ${feedDir} to ${packagesDir} ...`,
);
await um.downloadUpdateAsync(update!, () => {});
await um.downloadUpdateAsync(update!, () => {
});
expect(
existsSync(path.join(packagesDir, "AvaloniaCrossPlat-1.0.11-full.nupkg")),

View File

@@ -1,4 +1,4 @@
import { VelopackApp, VelopackLocatorConfig } from "../src/index";
import { VelopackApp, VelopackLocatorConfig, setVelopackLogger } from "../src";
import { shortDelay, isWindows } from "./helper";
class HookTester {
@@ -37,7 +37,7 @@ class HookTester {
tester.firstRun = true;
tester.version = ver;
});
builder.setLogger((level, msg) => {
setVelopackLogger((level, msg) => {
console.log(level, msg);
});
return [builder, tester];