Delete Tests directory
This commit is contained in:
@@ -1,77 +0,0 @@
|
|||||||
-- Tests/QuestieLearner_spec.lua
|
|
||||||
require("Tests/wow_api_mock")
|
|
||||||
|
|
||||||
describe("QuestieLearner", function()
|
|
||||||
local QuestieLearner
|
|
||||||
|
|
||||||
setup(function()
|
|
||||||
-- Mocking QuestieLoader for this test
|
|
||||||
_G.QuestieLoader.ImportModule = function(_, name)
|
|
||||||
if name == "QuestieDB" then return _G.QuestieDB end
|
|
||||||
if name == "QuestieQuest" then return _G.QuestieQuest end
|
|
||||||
if name == "QuestiePlayer" then return _G.QuestiePlayer end
|
|
||||||
if name == "QuestLogCache" then return _G.QuestLogCache end
|
|
||||||
if name == "QuestieCompat" then return _G.QuestieCompat end
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
_G.QuestieLoader.CreateModule = function(_, name)
|
|
||||||
_G[name] = {}
|
|
||||||
return _G[name]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Load the module (this assumes busted is run from project root)
|
|
||||||
package.loaded["Modules/QuestieLearner"] = nil
|
|
||||||
QuestieLearner = require("Modules/QuestieLearner")
|
|
||||||
|
|
||||||
-- Initialize
|
|
||||||
QuestieLearner:Initialize()
|
|
||||||
end)
|
|
||||||
|
|
||||||
it("should scale coordinates by 100 in OnCombatLogEvent", function()
|
|
||||||
-- Simulated combat log event info (npcId 21878)
|
|
||||||
local unitGUID = "Creature-0-1234-567-89-21878-0000000000"
|
|
||||||
local unitName = "Felboar"
|
|
||||||
|
|
||||||
-- Mock the player position to return raw decimals 0.35, 0.45
|
|
||||||
_G.QuestieCompat.GetCurrentPlayerPosition = function()
|
|
||||||
return 946, 0.35, 0.45
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Trigger event
|
|
||||||
QuestieLearner:OnCombatLogEvent(GetTime(), "UNIT_DIED", false, unitGUID, unitName, 0, 0, unitGUID, unitName, 0, 0)
|
|
||||||
|
|
||||||
-- The cache should store 35.0, 45.0
|
|
||||||
local cached = QuestieLearner.private.recentKills[unitGUID]
|
|
||||||
assert.is_not_nil(cached)
|
|
||||||
assert.are.equal(35.0, cached.x)
|
|
||||||
assert.are.equal(45.0, cached.y)
|
|
||||||
end)
|
|
||||||
|
|
||||||
it("should only learn spell casts that are quest objectives", function()
|
|
||||||
-- Reset data
|
|
||||||
Questie.db.global.learnedData.queries = {}
|
|
||||||
|
|
||||||
-- Case 1: Matching objective
|
|
||||||
local questId = 12345
|
|
||||||
local spellId = 29228 -- Flame Shock
|
|
||||||
|
|
||||||
_G.QuestieDB.GetQuest = function(_, id)
|
|
||||||
return {
|
|
||||||
Id = id,
|
|
||||||
Objectives = {
|
|
||||||
{ type = "spell", id = spellId }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
_G.QuestLogCache.GetQuestID = function() return questId end
|
|
||||||
|
|
||||||
QuestieLearner:LearnSpellCast(spellId, "Flame Shock", "Enemy NPC")
|
|
||||||
|
|
||||||
-- Result: data should have a log for this quest/spell
|
|
||||||
assert.is_not_nil(Questie.db.global.learnedData.quests[questId])
|
|
||||||
assert.is_not_nil(Questie.db.global.learnedData.quests[questId][3]) -- spell node
|
|
||||||
assert.are.equal(spellId, Questie.db.global.learnedData.quests[questId][3][1])
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
-- Tests/wow_api_mock.lua
|
|
||||||
-- Minimal mock of World of Warcraft API for Busted unit tests
|
|
||||||
|
|
||||||
_G = _G or {}
|
|
||||||
|
|
||||||
-- Mock Globals
|
|
||||||
_G.Questie = {
|
|
||||||
DEBUG_LEARNER = "LEARNER",
|
|
||||||
DEBUG_DEVELOP = "DEVELOP",
|
|
||||||
db = {
|
|
||||||
global = {
|
|
||||||
learnedData = {
|
|
||||||
npcs = {},
|
|
||||||
quests = {},
|
|
||||||
items = {},
|
|
||||||
objects = {},
|
|
||||||
settings = {
|
|
||||||
learnQuests = true,
|
|
||||||
learnNPCs = true,
|
|
||||||
learnItems = true,
|
|
||||||
learnObjects = true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
profile = {
|
|
||||||
learnedData = {
|
|
||||||
settings = {
|
|
||||||
learnQuests = true,
|
|
||||||
learnNPCs = true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Debug = function(self, level, ...)
|
|
||||||
-- print("[" .. tostring(level) .. "]", ...)
|
|
||||||
end,
|
|
||||||
Error = function(self, ...)
|
|
||||||
-- print("[ERROR]", ...)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
_G.QuestieLoader = {
|
|
||||||
ImportModule = function(self, name)
|
|
||||||
if name == "QuestieDB" then return _G.QuestieDB end
|
|
||||||
if name == "QuestieQuest" then return _G.QuestieQuest end
|
|
||||||
if name == "QuestiePlayer" then return _G.QuestiePlayer end
|
|
||||||
if name == "QuestLogCache" then return _G.QuestLogCache end
|
|
||||||
if name == "QuestieLib" then return {} end
|
|
||||||
if name == "QuestieCompat" then return _G.QuestieCompat end
|
|
||||||
return {}
|
|
||||||
end,
|
|
||||||
CreateModule = function(self, name)
|
|
||||||
_G[name] = {}
|
|
||||||
return _G[name]
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
_G.QuestieDB = {
|
|
||||||
npcDataOverrides = {},
|
|
||||||
QueryNPCSingle = function() return nil end,
|
|
||||||
GetQuest = function() return nil end,
|
|
||||||
}
|
|
||||||
|
|
||||||
_G.QuestieCompat = {
|
|
||||||
GetCurrentPlayerPosition = function() return 1, 0.5, 0.5 end,
|
|
||||||
}
|
|
||||||
|
|
||||||
_G.QuestiePlayer = {
|
|
||||||
GetPlayerLevel = function() return 70 end,
|
|
||||||
}
|
|
||||||
|
|
||||||
_G.QuestLogCache = {
|
|
||||||
GetQuestID = function() return 123 end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- WoW Functions
|
|
||||||
_G.GetTime = function() return os.time() end
|
|
||||||
_G.time = os.time
|
|
||||||
_G.floor = math.floor
|
|
||||||
_G.UnitName = function(unit) return "TestUnit" end
|
|
||||||
_G.UnitLevel = function(unit) return 70 end
|
|
||||||
_G.UnitGUID = function(unit) return "Creature-0-1234-567-89-1000-0000000000" end
|
|
||||||
_G.GetRealZoneText = function() return "Shadowmoon Valley" end
|
|
||||||
_G.GetInstanceInfo = function() return "Shadowmoon Valley", nil, nil, nil, nil, nil, nil, 530 end
|
|
||||||
_G.C_Timer = {
|
|
||||||
After = function(duration, callback) callback() end,
|
|
||||||
}
|
|
||||||
_G.CreateFrame = function() return { RegisterEvent = function() end, SetScript = function() end } end
|
|
||||||
|
|
||||||
return _G
|
|
||||||
Reference in New Issue
Block a user