mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
e3d3936156
- Added bootstrap functionality to initialize the Electron application. - Created a new paths module to manage application paths and URLs. - Introduced a shutdown service to handle graceful application shutdowns. - Refactored error logging to use a dedicated logger module. - Implemented process killing logic for NodeCG processes across platforms. - Established navigation policies for internal and external URL handling in windows. - Developed window service for creating and managing application windows. - Added tests for application paths, application controller, navigation policies, process killer, and shutdown service.
33 lines
820 B
TypeScript
33 lines
820 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { createShutdownService } from "../main/app/shutdown-service";
|
|
|
|
test("shutdown service reuses the same stop promise while stopping", async () => {
|
|
let stopCalls = 0;
|
|
let releaseStop: () => void = () => {
|
|
throw new Error("stop promise was not created");
|
|
};
|
|
const service = createShutdownService(
|
|
() =>
|
|
new Promise<void>((resolve) => {
|
|
stopCalls += 1;
|
|
releaseStop = resolve;
|
|
}),
|
|
);
|
|
|
|
const first = service.stop();
|
|
const second = service.stop();
|
|
|
|
assert.equal(first, second);
|
|
assert.equal(stopCalls, 1);
|
|
assert.equal(service.getState(), "stopping");
|
|
|
|
releaseStop();
|
|
await first;
|
|
|
|
assert.equal(service.getState(), "stopped");
|
|
await service.stop();
|
|
assert.equal(stopCalls, 1);
|
|
});
|