mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-09 04:23:45 -05:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
let userUtils = require('./../../dev-tools/users-utils.js');
|
|
let User = userUtils.User;
|
|
|
|
describe('Simulator abstraction layer features', function () {
|
|
describe('Battle', function () {
|
|
describe('player identifiers', function () {
|
|
let p1, p2, room;
|
|
afterEach(function () {
|
|
if (p1) {
|
|
p1.disconnectAll();
|
|
p1.destroy();
|
|
}
|
|
if (p2) {
|
|
p2.disconnectAll();
|
|
p2.destroy();
|
|
}
|
|
if (room) room.expire();
|
|
});
|
|
|
|
it('should not get out of sync in rated battles on rename', function () {
|
|
let packedTeam = 'Weavile||lifeorb||swordsdance,knockoff,iceshard,iciclecrash|Jolly|,252,,,4,252|||||';
|
|
p1 = new User();
|
|
p2 = new User();
|
|
p1.forceRename("Missingno."); // Don't do this at home
|
|
room = Rooms.global.startBattle(p1, p2, 'customgame', packedTeam, packedTeam, {rated: true});
|
|
if (!room.active) {
|
|
room.joinBattle(p1, packedTeam);
|
|
room.joinBattle(p2, packedTeam);
|
|
}
|
|
p1.resetName();
|
|
for (let i = 0; i < room.battle.playerids.length; i++) {
|
|
let curId = room.battle.playerids[i];
|
|
assert.strictEqual(room.battle.playerTable[curId], 'p' + (i + 1));
|
|
if (!curId) {
|
|
assert.ok(!room.battle.players[i]);
|
|
} else {
|
|
assert.strictEqual(curId, room.battle.players[i].userid);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|