Skip to content

Commit

Permalink
Updated tests so that they are all passsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
linguini1 committed Sep 5, 2023
1 parent 500e9b0 commit afcd3e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lua/pulse/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ end
--- @param timer string The timer name
--- @return boolean success True if the timer was removed, false if the timer did not exist
M.remove = function(timer)
local timer_obj = M._timers[timer]
if not timer then
local obj = M._timers[timer]
if not obj then
vim.notify("Timer " .. timer .. "does not exist.", vim.log.levels.ERROR, {})
return false
else
timer_obj.teardown()
obj.teardown()
M._timers[timer] = nil
return true
end
Expand Down
12 changes: 7 additions & 5 deletions tests/test.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
assert = require("luassert")

describe("pulse", function()
before_each(function() package.loaded["pulse"] = nil end) -- Unload pulse for each test

it("can be required", function() assert.is_true(pcall(require, "pulse")) end)

it("can be set up with default options", function()
Expand All @@ -18,15 +20,15 @@ describe("pulse", function()
local pulse = require("pulse")
pulse.setup()
assert.is_true(pulse.add("test", 15, "This is a test timer!", true))
assert.is_true(pulse._timers["test"])
assert.is.truthy(pulse._timers["test"])
assert.is_true(pulse._timers["test"].enabled())
end)

it("can have a timer added which is disabled", function()
local pulse = require("pulse")
pulse.setup()
assert.is_true(pulse.add("test", 15, "This is a test timer!", true))
assert.is_true(pulse._timers["test"])
assert.is_true(pulse.add("test", 15, "This is a test timer!", false))
assert.is.truthy(pulse._timers["test"])
assert.is_not_true(pulse._timers["test"].enabled())
end)

Expand Down Expand Up @@ -67,7 +69,7 @@ describe("pulse", function()
local pulse = require("pulse")
pulse.setup()
assert.is_true(pulse.add("test", 30, "This is a test timer!", true))
local hours, minutes = pulse.status("timer")
local hours, minutes = pulse.status("test")
assert.equal(0, hours)
assert.equal(30, minutes)
end)
Expand All @@ -76,7 +78,7 @@ describe("pulse", function()
local pulse = require("pulse")
pulse.setup()
assert.is_true(pulse.add("test", 30, "This is a test timer!", false))
local hours, minutes = pulse.status("timer")
local hours, minutes = pulse.status("test")
assert.equal(0, hours)
assert.equal(30, minutes)
end)
Expand Down

0 comments on commit afcd3e1

Please sign in to comment.