pokemon-showdown/test/simulator/misc/dex.js
Kirk Scheibelhut 4e421c1bd9 Refactor getEffect for speed safely (#5201)
Rollforward of 7a20245 which retains the `hasOwnProperty` checks.

Also changes the method to call `toId` earlier and use the id
as the key to the cache to ensure 'Stealth Rock' and 'stealthrock'
return the same. NOTE: 'move: Stealth Rock' and 'Stealth Rock' will
still continue to return different results.
2019-02-23 19:28:06 -06:00

34 lines
1.2 KiB
JavaScript

'use strict';
const assert = require('./../../assert');
describe('Mod loader', function () {
it.skip('should work fine in any order', function () {
{
Chat.uncacheTree('./sim/dex');
let Dex = require('./../../../sim/dex');
assert.strictEqual(Dex.mod('gen2').getTemplate('nidoking').learnset.bubblebeam.join(','), '1M');
assert.strictEqual(Dex.mod('gen2').getMove('crunch').secondaries[0].boosts.def, undefined);
}
{
Chat.uncacheTree('./sim/dex');
let Dex = require('./../../../sim/dex');
Dex.mod('gen2').getTemplate('nidoking');
Dex.mod('gen4').getMove('crunch');
assert.strictEqual(Dex.mod('gen2').getTemplate('nidoking').learnset.bubblebeam.join(','), '1M');
assert.strictEqual(Dex.mod('gen2').getMove('crunch').secondaries[0].boosts.def, undefined);
}
});
});
describe('Dex#getEffect', function () {
it('returns the same object for the same id', function () {
assert.strictEqual(Dex.getEffect('Stealth Rock'), Dex.getEffect('stealthrock'));
assert.notStrictEqual(Dex.getEffect('move: Stealth Rock'), Dex.getEffect('stealthrock'));
});
it('does not return elements from the Object prototype', function () {
assert.false(Dex.getEffect('constructor').exists);
});
});