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.
This commit is contained in:
1 parent
c59a705d05
commit
7fda3db472
7 files changed
+870
No files matched your search
@@ -0,0 +1,88 @@
|
||||
-- Minimal WoW API mocks for offline testing.
|
||||
-- Fixtures are scriptable: set MockItems / MockEquipped before calling addon code.
|
||||
|
||||
_G.UIParent = {}
|
||||
|
||||
_G.CopyTable = function(t)
|
||||
if type(t) ~= "table" then return t end
|
||||
local out = {}
|
||||
for k, v in pairs(t) do
|
||||
out[k] = v
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
_G.MockItems = {} -- itemID -> { name = string, stats = table (WoW API keys) }
|
||||
_G.MockEquipped = {} -- inventory slotID -> itemID
|
||||
|
||||
local function itemLink(itemID)
|
||||
local name = _G.MockItems[itemID] and _G.MockItems[itemID].name or ("item" .. itemID)
|
||||
return "|Hitem:" .. itemID .. ":0:0:0:0:0:0:0:0|h[" .. name .. "]|h"
|
||||
end
|
||||
_G.MockItemLink = itemLink
|
||||
|
||||
function GetItemInfo(itemID)
|
||||
local it = _G.MockItems[itemID]
|
||||
if not it then return nil end
|
||||
return it.name, itemLink(itemID), 4, 100, 70
|
||||
end
|
||||
|
||||
function GetItemStats(link)
|
||||
local itemID = tonumber(string.match(link, "item:(%d+)"))
|
||||
local it = _G.MockItems[itemID]
|
||||
return it and it.stats or nil
|
||||
end
|
||||
|
||||
function GetInventoryItemLink(_, slotID)
|
||||
local itemID = _G.MockEquipped[slotID]
|
||||
if not itemID then return nil end
|
||||
return itemLink(itemID)
|
||||
end
|
||||
|
||||
function UnitClass() return "Priest", "PRIEST" end
|
||||
function GetTalentTabInfo() return 0, 0, 0, 0 end
|
||||
|
||||
function ChatEdit_InsertLink() end
|
||||
function DressUpItemLink() end
|
||||
function IsShiftKeyDown() return false end
|
||||
function IsControlKeyDown() return false end
|
||||
|
||||
local function makeChild()
|
||||
return setmetatable({}, {
|
||||
__index = function(_, key)
|
||||
return function(_, ...) return nil end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
local function makeFrame()
|
||||
local frame = { fonts = {}, textures = {} }
|
||||
return setmetatable(frame, {
|
||||
__index = function(self, key)
|
||||
if key == "CreateFontString" then
|
||||
return function()
|
||||
local fs = makeChild()
|
||||
table.insert(self.fonts, fs)
|
||||
return fs
|
||||
end
|
||||
elseif key == "CreateTexture" then
|
||||
return function()
|
||||
local tx = makeChild()
|
||||
table.insert(self.textures, tx)
|
||||
return tx
|
||||
end
|
||||
end
|
||||
return function(_, ...) return self end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
_G.MockFrames = {}
|
||||
function CreateFrame()
|
||||
local f = makeFrame()
|
||||
table.insert(_G.MockFrames, f)
|
||||
return f
|
||||
end
|
||||
|
||||
_G.GameTooltip = makeFrame()
|
||||
_G.SlashCmdList = {}
|
||||
Reference in new issue
Block a user