From bf6692d11d6982877795c9140fb896a48765f2d5 Mon Sep 17 00:00:00 2001 From: Elttob Date: Fri, 4 Feb 2022 05:07:29 +0000 Subject: [PATCH] Add Hydrate unit tests --- test/Instances/Hydrate.spec.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/Instances/Hydrate.spec.lua diff --git a/test/Instances/Hydrate.spec.lua b/test/Instances/Hydrate.spec.lua new file mode 100644 index 000000000..8fa9f3b5e --- /dev/null +++ b/test/Instances/Hydrate.spec.lua @@ -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 \ No newline at end of file