pokemon-showdown/test/application/rooms.js
Guangcong Luo 341ab3b684 Refactor simulator.js to new RoomGame API
This is a huge refactor that's a half-scratch rewrite of simulator.js.

Everything seems to be working so far, but with such a huge change,
I wouldn't be surprised if something went wrong.
2015-12-03 18:30:47 -06:00

50 lines
1.6 KiB
JavaScript

'use strict';
const assert = require('assert');
let userUtils = require('./../../dev-tools/users-utils.js');
let User = userUtils.User;
describe('Rooms features', function () {
describe('Rooms', function () {
describe('Rooms.get', function () {
it('should be a function', function () {
assert.strictEqual(typeof Rooms.get, 'function');
});
it('should be equal to `Rooms`', function () {
assert.strictEqual(Rooms.get, Rooms);
});
});
describe('Rooms.rooms', function () {
it('should have null prototype', function () {
assert.strictEqual(Object.getPrototypeOf(Rooms.rooms), null);
});
it('should not have a native `constructor`', function () {
assert.ok(Rooms.rooms.constructor === undefined || Rooms.rooms.constructor instanceof Rooms.Room);
});
});
});
describe('BattleRoom', function () {
let room;
afterEach(function () {
if (room) room.expire();
});
it('should allow two users to join the battle', function () {
let p1 = new User();
let p2 = new User();
let packedTeam = 'Weavile||lifeorb||swordsdance,knockoff,iceshard,iciclecrash|Jolly|,252,,,4,252|||||';
let options = [{rated: false, tour: false}, {rated: false, tour: true}, {rated: true, tour: false}, {rated: true, tour: true}];
options.forEach(function (option) {
room = Rooms.global.startBattle(p1, p2, 'customgame', packedTeam, packedTeam, option);
assert.ok(room.battle.p1 && room.battle.p2); // Automatically joined
// assert.ok(room.joinBattle(p1, packedTeam));
// assert.ok(room.joinBattle(p2, packedTeam));
});
});
});
});