Files
amibis/Amibis/Tests/test_data.lua
T
dfj 7fda3db472 Add offline unit test suite for data and core logic
76 tests covering BIS data integrity (all classes/specs/phases, slot
shape, spot checks), ScanItemStats alias aggregation (Frozen
Shadoweave double-count regression), CompareGear upgrade ranking with
spec-specific stat keys, phase resolution, and latest-phase completion.
Runs with any Lua 5.3+ interpreter via mocked WoW API; no client
required. Not referenced in the .toc.
2026-10-11 16:00:24 +02:00

146 lines
5.4 KiB
Lua

-- Data integrity tests for BISLists.lua — run offline, no WoW client needed.
local _, ns = ...
local BIS = ns.Data.BISLists
local VALID_SLOTS = {
Head = true, Neck = true, Shoulder = true, Back = true, Chest = true,
Wrist = true, Hands = true, Waist = true, Legs = true, Feet = true,
Finger0 = true, Finger1 = true, Trinket0 = true, Trinket1 = true,
MainHand = true, SecondaryHand = true, Ranged = true,
}
local function validate_entry(slot, entry)
expect(VALID_SLOTS[slot]).toBeTruthy()
expect(type(entry.itemID)).toEqual("number")
expect(entry.itemID > 0).toBeTruthy()
expect(type(entry.name)).toEqual("string")
expect(#entry.name > 0).toBeTruthy()
expect(type(entry.source)).toEqual("string")
expect(#entry.source > 0).toBeTruthy()
if entry.enchant then
expect(type(entry.enchant.id)).toEqual("number")
expect(type(entry.enchant.name)).toEqual("string")
expect(#entry.enchant.name > 0).toBeTruthy()
end
end
describe("BIS data registry", function()
local classes = BIS:GetAvailableClasses()
it("covers all 9 classes", function()
expect(#classes).toEqual(9)
end)
for _, class in ipairs(classes) do
local specs = BIS:GetAvailableSpecs(class)
table.sort(specs)
it(class .. " has all 3 specs", function()
expect(#specs).toEqual(3)
end)
for _, spec in ipairs(specs) do
it(class .. "/" .. spec .. " lists are well-formed", function()
local phases = BIS:GetAvailablePhases(class, spec)
expect(#phases > 0).toBeTruthy()
for _, phase in ipairs(phases) do
local list = BIS:GetBISList(class, spec, phase)
expect(list).toBeTruthy()
local count = 0
for slot, entry in pairs(list) do
count = count + 1
validate_entry(slot, entry)
end
expect(count >= 8).toBeTruthy()
end
end)
end
end
end)
describe("phase ordering and resolution", function()
it("returns phases in canonical order", function()
local phases = BIS:GetAvailablePhases("PRIEST", "Shadow")
expect(phases[1]).toEqual("T4")
expect(phases[2]).toEqual("T5")
expect(phases[3]).toEqual("T6")
end)
it("reports the latest phase for every spec", function()
for _, class in ipairs(BIS:GetAvailableClasses()) do
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) do
expect(BIS:GetLatestPhase(class, spec)).toEqual("T6")
end
end
end)
it("keeps the saved phase when it exists", function()
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T6")).toEqual("T6")
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T5")).toEqual("T5")
end)
it("falls back to the first available phase", function()
expect(BIS:ResolvePhase("PALADIN", "Protection", "T5")).toEqual("T4")
expect(BIS:ResolvePhase("DRUID", "Feral Combat", "T5")).toEqual("T4")
expect(BIS:ResolvePhase("DRUID", "Balance", "T6")).toEqual("T6")
end)
it("returns preferred phase for unknown class", function()
expect(BIS:ResolvePhase("DEATHKNIGHT", "Frost", "T5")).toEqual("T5")
end)
it("returns nil lookup for unknown spec", function()
expect(BIS:GetBISList("PRIEST", "Nonexistent", "T6")).toBeNil()
end)
end)
describe("known T6 spot checks", function()
it("shadow priest T6 head is the Hyjal token", function()
local list = BIS:GetBISList("PRIEST", "Shadow", "T6")
expect(list["Head"].itemID).toEqual(31064)
expect(list["Head"].name).toEqual("Hood of Absolution")
end)
it("discipline priest shares the holy T6 list", function()
expect(BIS:GetBISList("PRIEST", "Discipline", "T6"))
.toEqual(BIS:GetBISList("PRIEST", "Holy", "T6"))
end)
it("hunter BM and MM share the T6 list", function()
expect(BIS:GetBISList("HUNTER", "Beast Mastery", "T6"))
.toEqual(BIS:GetBISList("HUNTER", "Marksmanship", "T6"))
end)
it("all three warlock specs share the T6 list", function()
local affliction = BIS:GetBISList("WARLOCK", "Affliction", "T6")
expect(BIS:GetBISList("WARLOCK", "Demonology", "T6")).toEqual(affliction)
expect(BIS:GetBISList("WARLOCK", "Destruction", "T6")).toEqual(affliction)
end)
end)
describe("T4 (Phase 1) data", function()
it("covers every spec", function()
for _, class in ipairs(BIS:GetAvailableClasses()) do
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) do
local list = BIS:GetBISList(class, spec, "T4")
expect(list).toBeTruthy()
end
end
end)
it("uses Karazhan/Gruul/Magtheridon gear", function()
local list = BIS:GetBISList("PRIEST", "Shadow", "T4")
expect(list["Head"].itemID).toEqual(24266)
expect(list["MainHand"].name).toEqual("Nathrezim Mindblade")
expect(list["MainHand"].source).toEqual("Karazhan - Prince Malchezaar")
end)
it("paladin protection prot has no T5 entry", function()
local phases = BIS:GetAvailablePhases("PALADIN", "Protection")
expect(phases[1]).toEqual("T4")
expect(phases[2]).toEqual("T6")
expect(BIS:GetBISList("PALADIN", "Protection", "T5")).toBeNil()
end)
end)