pokemon-showdown/test/application/process-manager.js
Guangcong Luo 87c41eb67c Rename simulator.js to room-battle.js
simulator.js doesn't actually contain the simulator, but is really just
an implementation of battles in the RoomGame interface.

Renames:
`Simulator.Battle` -> `Rooms.RoomBattle`
`Simulator.BattlePlayer` -> `Rooms.RoomBattlePlayer`
`Simulator.SimulatorManager` -> `Rooms.SimulatorManager`
`Simulator.SimulatorProcess` -> `Rooms.SimulatorProcess`
`Simulator.create` -> no longer exists, use `new Rooms.RoomBattle(...)`
2016-10-21 13:21:12 -05:00

62 lines
1.9 KiB
JavaScript

'use strict';
const assert = require('assert');
const path = require('path');
const ProcessManager = require('../../process-manager');
const ProcessWrapper = ProcessManager.ProcessWrapper;
// const DatasearchManager = require('../../chat-plugins/datasearch.js').DatasearchManager;
// const SimulatorManager = require('../../room-battle.js').SimulatorManager;
// const TeamValidatorManager = require('../../team-validator.js').TeamValidatorManager;
// const VerifierManager = require('../../verifier.js').VerifierManager;
// DO NOT CLEAR PROCESSMANAGER'S CACHE DURING THESE TESTS
// Delete the ProcessManager instances from it manually unless you want to break
// other tests that rely on what's already there at the beginning of these tests
// and watch the world burn.
describe('ProcessManager', function () {
it('should construct', function () {
let pm;
let cacheSize = ProcessManager.cache.size;
assert.doesNotThrow(() => {
pm = new ProcessManager({
execFile: path.resolve('./process-manager'),
maxProcesses: 0,
isChatBased: false,
});
});
assert.strictEqual(ProcessManager.cache.size, cacheSize + 1);
assert.ok(ProcessManager.cache.delete(pm));
});
describe('ProcessWrapper', function () {
beforeEach(function () {
this.pm = new ProcessManager({
execFile: path.resolve('./process-manager'),
maxProcesses: 0,
isChatBased: false,
});
});
afterEach(function () {
// Temporary until final process-manager.js refactor
this.pm.processes.forEach(pw => {
pw.process.removeAllListeners('message');
pw.process.disconnect();
pw.process = null;
pw.removeAllListeners('message');
pw.pendingTasks.clear();
pw.PM.processes.splice(pw.PM.processes.indexOf(pw), 1);
pw.PM = null;
});
ProcessManager.cache.delete(this.pm);
});
it('should construct', function () {
assert.doesNotThrow(() => new ProcessWrapper(this.pm));
});
});
});