-- Slash-command tests: /amibis spec 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)