pokemon-showdown/test/main.js
Guangcong Luo 8f81cfa4de Run tests on port 18003
Port 18003 was chosen at random, but the point is not to use the same
port as PS itself is running on.

This might not be the best approach, but it probably at least beats
running it on the port in config.js and conflicting with an active
PS process.
2015-03-03 01:52:50 -05:00

52 lines
1.6 KiB
JavaScript

var assert = require('assert');
before('initialization', function () {
this.timeout(0); // Remove timeout limitation
global.overridePort = 18003;
require('./../app.js');
process.listeners('uncaughtException').forEach(function (listener) {
process.removeListener('uncaughtException', listener);
});
// Run the battle engine in the main process to keep our sanity
var BattleEngine = global.BattleEngine = require('./../battle-engine.js');
process.listeners('message').forEach(function (listener) {
process.removeListener('message', listener);
});
// Turn IPC methods into no-op
BattleEngine.Battle.prototype.send = function () {};
BattleEngine.Battle.prototype.receive = function () {};
});
describe('Native timer/event loop globals', function () {
var globalList = ['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate'];
globalList.forEach(function (elem) {
describe('`' + elem + '`', function () {
it('should be a global function', function () {
assert.strictEqual(typeof global[elem], 'function');
});
});
});
});
describe('Custom globals', function () {
var globalList = [
'Config', 'ResourceMonitor', 'toId', 'toName', 'string', 'LoginServer',
'Users', 'Rooms', 'Verifier', 'CommandParser', 'Simulator', 'Tournaments',
'Dnsbl', 'Cidr', 'Sockets', 'Tools', 'TeamValidator'
];
globalList.forEach(function (elem) {
describe('`' + elem + '`', function () {
it('should be a global', function () {
assert.ok(global.hasOwnProperty(elem));
});
});
});
});
describe('Battle simulation', function () {
require('./simulator');
});