File size: 1,548 Bytes
5c2ed06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';

const assert = require('./../../assert');
const common = require('./../../common');

let battle;

describe('Immunity', () => {
	afterEach(() => {
		battle.destroy();
	});

	it('should make the user immune to poison', () => {
		battle = common.createBattle([[
			{ species: 'Snorlax', ability: 'immunity', moves: ['curse'] },
		], [
			{ species: 'Crobat', ability: 'infiltrator', moves: ['toxic'] },
		]]);
		assert.constant(() => battle.p1.active[0].status, () => battle.makeChoices('move curse', 'move toxic'));
	});

	it('should cure poison if a Pokemon receives the ability', () => {
		battle = common.createBattle([[
			{ species: 'Snorlax', ability: 'thickfat', moves: ['curse'] },
		], [
			{ species: 'Crobat', ability: 'immunity', moves: ['toxic', 'skillswap'] },
		]]);
		const target = battle.p1.active[0];
		assert.sets(() => target.status, 'tox', () => battle.makeChoices('move curse', 'move toxic'));
		assert.sets(() => target.status, '', () => battle.makeChoices('move curse', 'move skillswap'));
	});

	it('should have its immunity to poison temporarily suppressed by Mold Breaker, but should cure the status immediately afterwards', () => {
		battle = common.createBattle([[
			{ species: 'Snorlax', ability: 'immunity', moves: ['curse'] },
		], [
			{ species: 'Crobat', ability: 'moldbreaker', moves: ['toxic'] },
		]]);
		battle.makeChoices('move curse', 'move toxic');
		assert.equal(battle.log.filter(line => line.match(/-status\|.*\|tox/)).length, 1);
		assert.equal(battle.p1.active[0].status, '');
	});
});