Skip to content

Commit

Permalink
Add Hydrate unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dphfox committed Feb 4, 2022
1 parent 8f2c025 commit bf6692d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/Instances/Hydrate.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local Package = game:GetService("ReplicatedStorage").Fusion
local Hydrate = require(Package.Instances.Hydrate)

return function()
it("should return the instance it was passed", function()
local ins = Instance.new("Folder")

expect(Hydrate(ins) {}).to.equal(ins)
end)

it("should apply properties to the instance", function()
local ins = Instance.new("Folder")

Hydrate(ins) {
Name = "Jeremy"
}

expect(ins.Name).to.equal("Jeremy")
end)

it("should not inhibit garbage collection", function()
local ref = setmetatable({}, {__mode = "v"})
do
ref[1] = Hydrate(Instance.new("Folder")) {}
end

local startTime = os.clock()
repeat
task.wait()
until ref[1] == nil or os.clock() > startTime + 5
expect(ref[1]).to.equal(nil)
end)
end

0 comments on commit bf6692d

Please sign in to comment.