Skip to content

Commit

Permalink
Improve the unit tests for action IDs
Browse files Browse the repository at this point in the history
This patch adds one new test which ensures that Luvent creates the
same ID for an action when adding that action to separate events.
Then the patch corrects an existing test; one test checks to see if an
action ID is a string but we should not do this as it can give the
wrong impression that IDs will always be strings, which is not true.
So the patch modifies the test to assert that the action ID is a
‘truthy’ value, i.e. anything Lua would consider true in a boolean
context, which is all the precision we actually need for that test.
  • Loading branch information
Eric James Michael Ritz committed Sep 3, 2013
1 parent 1ea08d5 commit d5610eb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/Luvent.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ describe("Basic action management", function ()

it("Returns an ID when adding an action", function ()
local id = event:addAction(noop)
assert.is.string(id)
assert.is.truthy(id)
end)

it("Returns the same ID for events sharing an action", function ()
local event2 = Luvent.newEvent()
local id1 = event:addAction(noop)
local id2 = event2:addAction(noop)

assert.are.equal(id1, id2)
end)

end)
Expand Down

0 comments on commit d5610eb

Please sign in to comment.