Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Oct 6, 2024
1 parent e2c949d commit 32152f0
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1452,5 +1452,64 @@ describe('calc', () => {
});
});
});
describe('Some moves should break screens before doing damage', () => {
inGens(3, 9, ({calculate, Pokemon, Move, Field}) => {
test('Brick Break should break screens', () => {
const pokemon = Pokemon('Mew');

const brickBreak = Move('Brick Break');
const otherMove = Move('Vital Throw', {overrides: {basePower: 75}});

const field = Field({defenderSide: {isReflect: true}});

const brickBreakResult = calculate(pokemon, pokemon, brickBreak, field);
expect(brickBreakResult.field.defenderSide.isReflect).toBe(false);

const otherMoveResult = calculate(pokemon, pokemon, otherMove, field);
expect(otherMoveResult.field.defenderSide.isReflect).toBe(true);

expect(brickBreakResult.range()[0]).toBeGreaterThan(otherMoveResult.range()[0]);
expect(brickBreakResult.range()[1]).toBeGreaterThan(otherMoveResult.range()[1]);
});
});
inGens(7, 9, ({calculate, Pokemon, Move, Field}) => {
test('Psychic Fangs should break screens', () => {
const pokemon = Pokemon('Mew');

const psychicFangs = Move('Psychic Fangs');
const otherMove = Move('Zen Headbutt', {overrides: {basePower: 75}});

const field = Field({defenderSide: {isReflect: true}});

const psychicFangsResult = calculate(pokemon, pokemon, psychicFangs, field);
expect(psychicFangsResult.field.defenderSide.isReflect).toBe(false);

const otherMoveResult = calculate(pokemon, pokemon, otherMove, field);
expect(otherMoveResult.field.defenderSide.isReflect).toBe(true);

expect(psychicFangsResult.range()[0]).toBeGreaterThan(otherMoveResult.range()[0]);
expect(psychicFangsResult.range()[1]).toBeGreaterThan(otherMoveResult.range()[1]);
});
});
inGen(9, ({calculate, Pokemon, Move, Field}) => {
test('Raging Bull should break screens', () => {
const pokemon = Pokemon('Tauros-Paldea-Aqua');

const ragingBull = Move('Raging Bull');
const otherMove = Move('Waterfall', {overrides: {basePower: 90}});

const field = Field({defenderSide: {isReflect: true}});

const ragingBullResult = calculate(pokemon, pokemon, ragingBull, field);
expect(ragingBullResult.field.defenderSide.isReflect).toBe(false);

const otherMoveResult = calculate(pokemon, pokemon, otherMove, field);
expect(otherMoveResult.field.defenderSide.isReflect).toBe(true);

expect(ragingBullResult.range()[0]).toBeGreaterThan(otherMoveResult.range()[0]);
expect(ragingBullResult.range()[1]).toBeGreaterThan(otherMoveResult.range()[1]);
});
});
});
});
});

0 comments on commit 32152f0

Please sign in to comment.