'use strict';

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

let battle;

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

	it('should fail when used against a Pokemon whose type is "???"', () => {
		battle = common.createBattle([[
			{ species: 'Arcanine', ability: 'intimidate', moves: ['burnup'] },
		], [
			{ species: 'Latias', ability: 'levitate', item: 'laggingtail', moves: ['reflecttype'] },
		]]);
		assert.constant(() => battle.p2.active[0].getTypes(), () => battle.makeChoices('move burnup', 'move reflecttype'));
	});

	it('should ignore the "???" type when used against a Pokemon whose type contains "???" and a non-added type', () => {
		battle = common.createBattle([[
			{ species: 'Latias', ability: 'levitate', item: 'laggingtail', moves: ['reflecttype', 'trickortreat'] },
		], [
			{ species: 'Moltres', ability: 'pressure', moves: ['burnup'] },
		]]);
		battle.makeChoices('move reflecttype', 'move burnup');
		assert.equal(battle.p1.active[0].getTypes().join('/'), 'Flying');
		battle.makeChoices('move trickortreat', 'move burnup');
		battle.makeChoices('move reflecttype', 'move burnup');
		assert.equal(battle.p1.active[0].getTypes().join('/'), 'Flying/Ghost');
	});

	it('should turn the "???" type into "Normal" when used against a Pokemon whose type is only "???" and an added type', () => {
		battle = common.createBattle([[
			{ species: 'Latias', ability: 'levitate', item: 'laggingtail', moves: ['reflecttype', 'trickortreat'] },
		], [
			{ species: 'Arcanine', ability: 'intimidate', moves: ['burnup'] },
		]]);
		battle.makeChoices('move trickortreat', 'move burnup');
		battle.makeChoices('move reflecttype', 'move burnup');
		assert.equal(battle.p1.active[0].getTypes().join('/'), 'Normal/Ghost');
	});
});
