Skip to content

Commit

Permalink
Add QueryResult test to validate that iteration is not unexpectedly…
Browse files Browse the repository at this point in the history
… terminated
  • Loading branch information
YetAnotherClown committed Aug 26, 2024
1 parent 04632d5 commit 4cd8183
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/__tests__/QueryResult.test.luau
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,39 @@ describe("QueryResult", function()
expect(num3).toEqual(3)
end
end)

it("Should not terminate iteration unexpectedly", function()
local snapshot = {
{
data = { 1, 2, 3 },
identifier = identifier,
sender = "NET_SERVER" :: "NET_SERVER",
},
{
data = { "a", "b", "c" },
identifier = Identifier.new(),
sender = "NET_SERVER" :: "NET_SERVER",
},
{
data = { 4, 6, 7 },
identifier = identifier,
sender = "NET_SERVER" :: "NET_SERVER",
},
} :: { { data: { any }, identifier: buffer, sender: any } }

local result = QueryResult.new(snapshot, identifier)

local n = 0
for i, sender, num1, num2, num3 in result do
expect(i).toEqual(expect.any("number"))
expect(sender).toEqual("NET_SERVER")
expect(num1).toEqual(expect.any("number"))
expect(num2).toEqual(expect.any("number"))
expect(num3).toEqual(expect.any("number"))

n += 1
end

expect(n).toEqual(2)
end)
end)

0 comments on commit 4cd8183

Please sign in to comment.