mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
test(main): completar fase 2 con cobertura de iconos y timing
This commit is contained in:
@@ -122,3 +122,71 @@ test("stopNodeCG envía SIGTERM y luego SIGKILL si el proceso no sale", async ()
|
||||
child.emit("exit", 0, null);
|
||||
await stopPromise;
|
||||
});
|
||||
|
||||
|
||||
test("stopNodeCG reutiliza la misma promesa cuando se invoca en paralelo", async () => {
|
||||
const child = new MockChildProcess(5555);
|
||||
|
||||
const manager = createNodecgProcessManager({
|
||||
isDev: true,
|
||||
nodecgPath: "/fake/nodecg",
|
||||
baseUrl: "http://127.0.0.1:9090",
|
||||
runtimeConfig: getBaseConfig(),
|
||||
log: () => undefined,
|
||||
deps: {
|
||||
pathExists: () => true,
|
||||
spawnProcess: () => child as unknown as import("node:child_process").ChildProcess,
|
||||
fetchUrl: async () => ({ ok: false, status: 404 } as Response),
|
||||
killProcess: () => undefined,
|
||||
setTimer: () => 0,
|
||||
stdoutWrite: () => undefined,
|
||||
stderrWrite: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
manager.startNodeCG();
|
||||
const firstStop = manager.stopNodeCG();
|
||||
const secondStop = manager.stopNodeCG();
|
||||
|
||||
assert.equal(firstStop, secondStop);
|
||||
|
||||
child.emit("exit", 0, null);
|
||||
await firstStop;
|
||||
});
|
||||
|
||||
test("stopNodeCG normaliza timeout negativo a cero", async () => {
|
||||
const child = new MockChildProcess(7777);
|
||||
const timeouts: number[] = [];
|
||||
|
||||
const manager = createNodecgProcessManager({
|
||||
isDev: true,
|
||||
nodecgPath: "/fake/nodecg",
|
||||
baseUrl: "http://127.0.0.1:9090",
|
||||
runtimeConfig: {
|
||||
...getBaseConfig(),
|
||||
nodecgKillTimeoutMs: -10,
|
||||
},
|
||||
log: () => undefined,
|
||||
deps: {
|
||||
pathExists: () => true,
|
||||
spawnProcess: () => child as unknown as import("node:child_process").ChildProcess,
|
||||
fetchUrl: async () => ({ ok: false, status: 404 } as Response),
|
||||
killProcess: () => undefined,
|
||||
setTimer: (handler, timeoutMs) => {
|
||||
timeouts.push(timeoutMs);
|
||||
handler();
|
||||
return 0;
|
||||
},
|
||||
stdoutWrite: () => undefined,
|
||||
stderrWrite: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
manager.startNodeCG();
|
||||
const stopPromise = manager.stopNodeCG();
|
||||
|
||||
assert.ok(timeouts.includes(0));
|
||||
|
||||
child.emit("exit", 0, null);
|
||||
await stopPromise;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user