Fix /amibis spec clear being stored as a spec override
The generic "spec <name>" branch matched before the "spec clear" check, so clearing an override set overrideSpec to "Clear" and the UI then looked for a spec called Clear instead of falling back to auto-detection. Check the clear command first, collapse whitespace so "spec clear" parses, and refresh the frame immediately when the override changes. Spec names are also title-cased per word now, so "/amibis spec beast mastery" resolves to "Beast Mastery". Add test_slash.lua covering set/clear, case/whitespace normalization, and the clear-as-spec-name regression. 93 tests passing.
This commit is contained in:
1 parent
907d274b3a
commit
912ed8f255
4 files changed
+76
-5
No files matched your search
@@ -0,0 +1,53 @@
|
||||
-- Slash-command tests: /amibis spec <name> and /amibis spec clear.
|
||||
local _, ns = ...
|
||||
|
||||
-- WoW exposes string:trim(); plain Lua does not.
|
||||
if not string.trim then
|
||||
function string.trim(s)
|
||||
return (s:gsub("^%s+", ""):gsub("%s+$", ""))
|
||||
end
|
||||
end
|
||||
|
||||
local function run(msg)
|
||||
local output = {}
|
||||
local realPrint = print
|
||||
print = function(text) table.insert(output, tostring(text)) end
|
||||
SlashCmdList["AMIBIS"](msg)
|
||||
print = realPrint
|
||||
return table.concat(output, "\n"), output
|
||||
end
|
||||
|
||||
describe("/amibis spec", function()
|
||||
before_each(function()
|
||||
AmibisCharDB.overrideSpec = nil
|
||||
end)
|
||||
|
||||
it("sets a spec override", function()
|
||||
run("spec Holy")
|
||||
expect(AmibisCharDB.overrideSpec).toEqual("Holy")
|
||||
end)
|
||||
|
||||
it("normalizes case and multi-word spec names", function()
|
||||
run(" SPEC beast mastery ")
|
||||
expect(AmibisCharDB.overrideSpec).toEqual("Beast Mastery")
|
||||
end)
|
||||
|
||||
it("clears the override instead of setting a spec named clear", function()
|
||||
AmibisCharDB.overrideSpec = "Shadow"
|
||||
local text = run("spec clear")
|
||||
expect(AmibisCharDB.overrideSpec).toBeNil()
|
||||
expect(text:find("cleared", 1, true)).toBeTruthy()
|
||||
end)
|
||||
|
||||
it("clears the override regardless of case or extra spaces", function()
|
||||
AmibisCharDB.overrideSpec = "Shadow"
|
||||
run(" SPEC CLEAR ")
|
||||
expect(AmibisCharDB.overrideSpec).toBeNil()
|
||||
end)
|
||||
|
||||
it("keeps the override when the spec name is missing", function()
|
||||
AmibisCharDB.overrideSpec = "Shadow"
|
||||
run("spec")
|
||||
expect(AmibisCharDB.overrideSpec).toEqual("Shadow")
|
||||
end)
|
||||
end)
|
||||
Reference in new issue
Block a user