Update achievement.test.ts

This commit is contained in:
damocleas 2025-08-19 17:01:41 -04:00 committed by GitHub
parent 8ff1dbda43
commit 9b10f312b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
describe("check some Achievement related stuff", () => { describe("check some Achievement related stuff", () => {
it("should check Achievement creation", () => { it("should check Achievement creation", () => {
const ach = new MoneyAchv("", "Achievement", 1000, null!, 100); const ach = new MoneyAchv("Achievement", 1000, null!, 100);
expect(ach.name).toBe("Achievement"); expect(ach.name).toBe("Achievement");
}); });
}); });
@ -27,7 +27,7 @@ describe("Achv", () => {
let achv: Achv; let achv: Achv;
beforeEach(() => { beforeEach(() => {
achv = new Achv("", "Test Achievement", "This is a test achievement", "test_icon", 10); achv = new Achv("Test Achievement", "This is a test achievement", "test_icon", 10);
}); });
it("should have the correct name", () => { it("should have the correct name", () => {
@ -53,11 +53,11 @@ describe("Achv", () => {
}); });
it("should return the correct tier based on the score", () => { it("should return the correct tier based on the score", () => {
const achv1 = new Achv("", "Test Achievement 1", "Test Description", "test_icon", 10); const achv1 = new Achv("Test Achievement 1", "Test Description", "test_icon", 10);
const achv2 = new Achv("", "Test Achievement 2", "Test Description", "test_icon", 25); const achv2 = new Achv("Test Achievement 2", "Test Description", "test_icon", 25);
const achv3 = new Achv("", "Test Achievement 3", "Test Description", "test_icon", 50); const achv3 = new Achv("Test Achievement 3", "Test Description", "test_icon", 50);
const achv4 = new Achv("", "Test Achievement 4", "Test Description", "test_icon", 75); const achv4 = new Achv("Test Achievement 4", "Test Description", "test_icon", 75);
const achv5 = new Achv("", "Test Achievement 5", "Test Description", "test_icon", 100); const achv5 = new Achv("Test Achievement 5", "Test Description", "test_icon", 100);
expect(achv1.getTier()).toBe(AchvTier.COMMON); expect(achv1.getTier()).toBe(AchvTier.COMMON);
expect(achv2.getTier()).toBe(AchvTier.GREAT); expect(achv2.getTier()).toBe(AchvTier.GREAT);
@ -68,7 +68,7 @@ describe("Achv", () => {
it("should validate the achievement based on the condition function", () => { it("should validate the achievement based on the condition function", () => {
const conditionFunc = vi.fn((args: any[]) => args[0] === 10); const conditionFunc = vi.fn((args: any[]) => args[0] === 10);
const achv = new Achv("", "Test Achievement", "Test Description", "test_icon", 10, conditionFunc); const achv = new Achv("Test Achievement", "Test Description", "test_icon", 10, conditionFunc);
expect(achv.validate([5])).toBe(false); expect(achv.validate([5])).toBe(false);
expect(achv.validate([10])).toBe(true); expect(achv.validate([10])).toBe(true);
@ -97,13 +97,13 @@ describe("MoneyAchv", () => {
}); });
it("should create an instance of MoneyAchv", () => { it("should create an instance of MoneyAchv", () => {
const moneyAchv = new MoneyAchv("", "Test Money Achievement", 10000, "money_icon", 10); const moneyAchv = new MoneyAchv("Test Money Achievement", 10000, "money_icon", 10);
expect(moneyAchv).toBeInstanceOf(MoneyAchv); expect(moneyAchv).toBeInstanceOf(MoneyAchv);
expect(moneyAchv instanceof Achv).toBe(true); expect(moneyAchv instanceof Achv).toBe(true);
}); });
it("should validate the achievement based on the money amount", () => { it("should validate the achievement based on the money amount", () => {
const moneyAchv = new MoneyAchv("", "Test Money Achievement", 10000, "money_icon", 10); const moneyAchv = new MoneyAchv("Test Money Achievement", 10000, "money_icon", 10);
scene.money = 5000; scene.money = 5000;
expect(moneyAchv.validate([])).toBe(false); expect(moneyAchv.validate([])).toBe(false);
@ -134,13 +134,13 @@ describe("RibbonAchv", () => {
}); });
it("should create an instance of RibbonAchv", () => { it("should create an instance of RibbonAchv", () => {
const ribbonAchv = new RibbonAchv("", "Test Ribbon Achievement", 10, "ribbon_icon", 10); const ribbonAchv = new RibbonAchv("Test Ribbon Achievement", 10, "ribbon_icon", 10);
expect(ribbonAchv).toBeInstanceOf(RibbonAchv); expect(ribbonAchv).toBeInstanceOf(RibbonAchv);
expect(ribbonAchv instanceof Achv).toBe(true); expect(ribbonAchv instanceof Achv).toBe(true);
}); });
it("should validate the achievement based on the ribbon amount", () => { it("should validate the achievement based on the ribbon amount", () => {
const ribbonAchv = new RibbonAchv("", "Test Ribbon Achievement", 10, "ribbon_icon", 10); const ribbonAchv = new RibbonAchv("Test Ribbon Achievement", 10, "ribbon_icon", 10);
scene.gameData.gameStats.ribbonsOwned = 5; scene.gameData.gameStats.ribbonsOwned = 5;
expect(ribbonAchv.validate([])).toBe(false); expect(ribbonAchv.validate([])).toBe(false);
@ -152,13 +152,13 @@ describe("RibbonAchv", () => {
describe("DamageAchv", () => { describe("DamageAchv", () => {
it("should create an instance of DamageAchv", () => { it("should create an instance of DamageAchv", () => {
const damageAchv = new DamageAchv("", "Test Damage Achievement", 250, "damage_icon", 10); const damageAchv = new DamageAchv("Test Damage Achievement", 250, "damage_icon", 10);
expect(damageAchv).toBeInstanceOf(DamageAchv); expect(damageAchv).toBeInstanceOf(DamageAchv);
expect(damageAchv instanceof Achv).toBe(true); expect(damageAchv instanceof Achv).toBe(true);
}); });
it("should validate the achievement based on the damage amount", () => { it("should validate the achievement based on the damage amount", () => {
const damageAchv = new DamageAchv("", "Test Damage Achievement", 250, "damage_icon", 10); const damageAchv = new DamageAchv("Test Damage Achievement", 250, "damage_icon", 10);
const numberHolder = new NumberHolder(200); const numberHolder = new NumberHolder(200);
expect(damageAchv.validate([numberHolder])).toBe(false); expect(damageAchv.validate([numberHolder])).toBe(false);
@ -170,13 +170,13 @@ describe("DamageAchv", () => {
describe("HealAchv", () => { describe("HealAchv", () => {
it("should create an instance of HealAchv", () => { it("should create an instance of HealAchv", () => {
const healAchv = new HealAchv("", "Test Heal Achievement", 250, "heal_icon", 10); const healAchv = new HealAchv("Test Heal Achievement", 250, "heal_icon", 10);
expect(healAchv).toBeInstanceOf(HealAchv); expect(healAchv).toBeInstanceOf(HealAchv);
expect(healAchv instanceof Achv).toBe(true); expect(healAchv instanceof Achv).toBe(true);
}); });
it("should validate the achievement based on the heal amount", () => { it("should validate the achievement based on the heal amount", () => {
const healAchv = new HealAchv("", "Test Heal Achievement", 250, "heal_icon", 10); const healAchv = new HealAchv("Test Heal Achievement", 250, "heal_icon", 10);
const numberHolder = new NumberHolder(200); const numberHolder = new NumberHolder(200);
expect(healAchv.validate([numberHolder])).toBe(false); expect(healAchv.validate([numberHolder])).toBe(false);
@ -188,13 +188,13 @@ describe("HealAchv", () => {
describe("LevelAchv", () => { describe("LevelAchv", () => {
it("should create an instance of LevelAchv", () => { it("should create an instance of LevelAchv", () => {
const levelAchv = new LevelAchv("", "Test Level Achievement", 100, "level_icon", 10); const levelAchv = new LevelAchv("Test Level Achievement", 100, "level_icon", 10);
expect(levelAchv).toBeInstanceOf(LevelAchv); expect(levelAchv).toBeInstanceOf(LevelAchv);
expect(levelAchv instanceof Achv).toBe(true); expect(levelAchv instanceof Achv).toBe(true);
}); });
it("should validate the achievement based on the level", () => { it("should validate the achievement based on the level", () => {
const levelAchv = new LevelAchv("", "Test Level Achievement", 100, "level_icon", 10); const levelAchv = new LevelAchv("Test Level Achievement", 100, "level_icon", 10);
const integerHolder = new NumberHolder(50); const integerHolder = new NumberHolder(50);
expect(levelAchv.validate([integerHolder])).toBe(false); expect(levelAchv.validate([integerHolder])).toBe(false);
@ -207,7 +207,6 @@ describe("LevelAchv", () => {
describe("ModifierAchv", () => { describe("ModifierAchv", () => {
it("should create an instance of ModifierAchv", () => { it("should create an instance of ModifierAchv", () => {
const modifierAchv = new ModifierAchv( const modifierAchv = new ModifierAchv(
"",
"Test Modifier Achievement", "Test Modifier Achievement",
"Test Description", "Test Description",
"modifier_icon", "modifier_icon",
@ -220,7 +219,6 @@ describe("ModifierAchv", () => {
it("should validate the achievement based on the modifier function", () => { it("should validate the achievement based on the modifier function", () => {
const modifierAchv = new ModifierAchv( const modifierAchv = new ModifierAchv(
"",
"Test Modifier Achievement", "Test Modifier Achievement",
"Test Description", "Test Description",
"modifier_icon", "modifier_icon",