diff --git a/spec/acc_spec.lua b/spec/acc_spec.lua index bf9be19..ba59313 100644 --- a/spec/acc_spec.lua +++ b/spec/acc_spec.lua @@ -1,34 +1,34 @@ ----@diagnostic disable: undefined-global -local helper = require("spec.helper") -local update = helper.update - -describe("acc", function() - before_each(function() - helper.reset() - helper.init() - end) - - after_each(function() - xero = nil - end) - - it("sets values at the right time", function() - xero.acc {1, 100, "bumpy"} - update(0.5) - assert.equal(nil, helper.get_mod("bumpy")) - update(1) - assert.equal("100", helper.get_mod("bumpy")) - end) - - it("adds when called multiple times", function() - xero.acc {1, 100, "bumpy"} - xero.acc {1, 100, "bumpy"} - xero.acc {1, 100, "bumpy"} - xero.acc {1, 100, "bumpy"} - xero.acc {1, 100, "bumpy"} - update(0.5) - assert.equal(nil, helper.get_mod("bumpy")) - update(1) - assert.equal("500", helper.get_mod("bumpy")) - end) -end) +---@diagnostic disable: undefined-global +local helper = require("spec.helper") +local update = helper.update + +describe("acc", function() + before_each(function() + helper.reset() + helper.init() + end) + + after_each(function() + xero = nil + end) + + it("sets values at the right time", function() + xero.acc {1, 100, "bumpy"} + update(0.5) + assert.equal(nil, helper.get_mod("bumpy")) + update(1) + assert.equal("100", helper.get_mod("bumpy")) + end) + + it("adds when called multiple times", function() + xero.acc {1, 100, "bumpy"} + xero.acc {1, 100, "bumpy"} + xero.acc {1, 100, "bumpy"} + xero.acc {1, 100, "bumpy"} + xero.acc {1, 100, "bumpy"} + update(0.5) + assert.equal(nil, helper.get_mod("bumpy")) + update(1) + assert.equal("500", helper.get_mod("bumpy")) + end) +end) diff --git a/spec/definemod_spec.lua b/spec/definemod_spec.lua index ed0ed45..0227ce8 100644 --- a/spec/definemod_spec.lua +++ b/spec/definemod_spec.lua @@ -24,5 +24,4 @@ describe("definemod", function() update(2) end) - -- TODO end) diff --git a/spec/eases_spec.lua b/spec/eases_spec.lua index 0ca621c..d1f926c 100644 --- a/spec/eases_spec.lua +++ b/spec/eases_spec.lua @@ -1,6 +1,5 @@ ---@diagnostic disable: undefined-global local helper = require("spec.helper") -local update = helper.update local function check_doesnt_crash(fn) for i = 0, 1, 0.2 do diff --git a/spec/helper.lua b/spec/helper.lua index 3f7060c..da59dac 100644 --- a/spec/helper.lua +++ b/spec/helper.lua @@ -30,33 +30,31 @@ local initcommand = "return " .. body:match('"%%(.-)"') initcommand = assert(loadstring(initcommand, "template/main.xml"))() function helper.init() - local h = helper - - h.foreground = mock.newactorframe() + helper.foreground = mock.newactorframe() loadfile = cachedloadfile - initcommand(h.foreground) + initcommand(helper.foreground) xero.loadfile = dummyloadfile xero.package.preload.mods = function() end - h.template = mock.newactor() - mock.add_child(h.foreground, h.template) - h.template:addcommand("Init", xero.init_command) - h.template:playcommand("Init") + helper.template = mock.newactor() + mock.add_child(helper.foreground, helper.template) + helper.template:addcommand("Init", xero.init_command) + helper.template:playcommand("Init") - h.layout = mock.newactorframe() - mock.add_child(h.foreground, h.layout) + helper.layout = mock.newactorframe() + mock.add_child(helper.foreground, helper.layout) local pp1 = mock.newactor("PP[1]") local pp2 = mock.newactor("PP[2]") local pc1 = mock.newactor("PC[1]") local pc2 = mock.newactor("PC[2]") local pj1 = mock.newactor("PJ[1]") local pj2 = mock.newactor("PJ[2]") - mock.add_child(h.layout, pp1) - mock.add_child(h.layout, pp2) - mock.add_child(h.layout, pc1) - mock.add_child(h.layout, pc2) - mock.add_child(h.layout, pj1) - mock.add_child(h.layout, pj2) + mock.add_child(helper.layout, pp1) + mock.add_child(helper.layout, pp2) + mock.add_child(helper.layout, pc1) + mock.add_child(helper.layout, pc2) + mock.add_child(helper.layout, pj1) + mock.add_child(helper.layout, pj2) end function helper.on() diff --git a/spec/node_spec.lua b/spec/node_spec.lua index bf6d61d..0dcbace 100644 --- a/spec/node_spec.lua +++ b/spec/node_spec.lua @@ -1,6 +1,5 @@ ---@diagnostic disable: undefined-global local helper = require("spec.helper") -local update = helper.update describe("node", function() before_each(function() diff --git a/spec/setdefault_spec.lua b/spec/setdefault_spec.lua index bd7efaa..2794fd9 100644 --- a/spec/setdefault_spec.lua +++ b/spec/setdefault_spec.lua @@ -1,6 +1,5 @@ ---@diagnostic disable: undefined-global local helper = require("spec.helper") -local update = helper.update describe("setdefault", function() before_each(function() diff --git a/spec/sort_spec.lua b/spec/sort_spec.lua index b4cfa01..acdecb4 100644 --- a/spec/sort_spec.lua +++ b/spec/sort_spec.lua @@ -1,6 +1,5 @@ ---@diagnostic disable: undefined-global local helper = require("spec.helper") -local update = helper.update describe("sort", function() setup(function() @@ -24,4 +23,4 @@ describe("sort", function() xero.stableSort(testtable,function(a, b) return a < b end) assert.is.same(testtable, {1,1,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,45,45,57,57,69,69,79,79,1000,1000}) end) -end) \ No newline at end of file +end) diff --git a/spec/spellcard_spec.lua b/spec/spellcard_spec.lua index 0948962..1f6892e 100644 --- a/spec/spellcard_spec.lua +++ b/spec/spellcard_spec.lua @@ -1,6 +1,5 @@ ---@diagnostic disable: undefined-global local helper = require("spec.helper") -local update = helper.update describe("spellcard plugin", function() before_each(function() @@ -15,6 +14,9 @@ describe("spellcard plugin", function() it("doesn't crash", function() local spellcards = xero.require('spellcards') spellcards.insert {0, 10, "my cool card of spelling", 1000, "#fcf"} + spellcards.insert {20, 30, "my cool card of spelling", 999, {1,0.75, 1}} helper.update(0) end) + + -- any more testing is really testing our mock more than the functionality end)