Skip to content

Commit

Permalink
chore: add utility unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Aug 5, 2024
1 parent 536030c commit c66eb72
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spec/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local utils = require("utils")

describe("findInArray", function()
it("should return the index of the found element", function()
local array = { { key = "hello" }, { key = "world" } }
local predicate = function(element)
return element.key == "world"
end
assert.are.same(2, utils.findInArray(array, predicate))
end)

it("should return nil if the element is not found", function()
local array = { { key = "hello" }, { key = "world" } }
local predicate = function(element)
return element.key == "foo"
end
assert.are.same(nil, utils.findInArray(array, predicate))
end)
end)

0 comments on commit c66eb72

Please sign in to comment.