From 035f5c06cf5e62635bc4cc6e971809a6c9a58751 Mon Sep 17 00:00:00 2001 From: Stephen Leitnick Date: Tue, 10 Dec 2024 11:11:11 -0500 Subject: [PATCH] Component --- ci/Test.luau | 4 +- modules/component/init.test.luau | 12 +- modules/shake/init.test.luau | 2 +- modules/streamable/Streamable.spec.luau | 137 -------------------- modules/streamable/StreamableUtil.spec.luau | 60 --------- test/wally.lock | 7 +- 6 files changed, 10 insertions(+), 212 deletions(-) delete mode 100644 modules/streamable/Streamable.spec.luau delete mode 100644 modules/streamable/StreamableUtil.spec.luau diff --git a/ci/Test.luau b/ci/Test.luau index 92a8f066..b62073a5 100644 --- a/ci/Test.luau +++ b/ci/Test.luau @@ -413,8 +413,8 @@ function Test.run(ancestors: { Instance }) out("---------") out(`{totalTests} Total`) - out(`{totalSuccesses} Pass`) - out(`{totalFails} Fail{if totalFails == 1 then "" else "s"}`) + out(`{totalSuccesses} Passed`) + out(`{totalFails} Failed`) out("---------") local tab = " " diff --git a/modules/component/init.test.luau b/modules/component/init.test.luau index 2485f733..18399c96 100644 --- a/modules/component/init.test.luau +++ b/modules/component/init.test.luau @@ -89,16 +89,16 @@ return function(ctx: Test.TestContext) taggedInstanceFolder.Parent = workspace end) - ctx:AfterEach(function() - taggedInstanceFolder:ClearAllChildren() - end) - ctx:AfterAll(function() taggedInstanceFolder:Destroy() TestComponentMain:Destroy() end) ctx:Describe("Component", function() + ctx:AfterEach(function() + taggedInstanceFolder:ClearAllChildren() + end) + ctx:Test("should capture start and stop events", function() local didStart = 0 local didStop = 0 @@ -135,8 +135,8 @@ return function(ctx: Test.TestContext) task.wait() local components = TestComponentMain:GetAll() ctx:Expect(components):ToBeA("table") - ctx:Expect(#components):ToBe(numComponents) - for _, c in ipairs(components) do + ctx:Expect(components):ToHaveLength(numComponents) + for _, c in components do ctx:Expect(table.find(instances, c.Instance)):ToBeOk() end end) diff --git a/modules/shake/init.test.luau b/modules/shake/init.test.luau index b7adb3a1..a336cc9b 100644 --- a/modules/shake/init.test.luau +++ b/modules/shake/init.test.luau @@ -77,11 +77,11 @@ return function(ctx: Test.TestContext) "Sustain", "PositionInfluence", "RotationInfluence", - "TimeFunction", } for _, field in clonedFields do ctx:Expect(shake1[field]):ToBe(shake2[field]) end + ctx:Expect(shake1.TimeFunction == shake2.TimeFunction):ToBe(true) end) ctx:Test("should clone a shake instance but ignore running state", function() diff --git a/modules/streamable/Streamable.spec.luau b/modules/streamable/Streamable.spec.luau deleted file mode 100644 index ee5a8510..00000000 --- a/modules/streamable/Streamable.spec.luau +++ /dev/null @@ -1,137 +0,0 @@ -return function() - local Streamable = require(script.Parent.Streamable) - - local instanceFolder - local instanceModel - - local function CreateInstance(name) - local folder = Instance.new("Folder") - folder.Name = name - folder.Archivable = false - folder.Parent = instanceFolder - return folder - end - - local function CreatePrimary() - local primary = Instance.new("Part") - primary.Anchored = true - primary.Parent = instanceModel - instanceModel.PrimaryPart = primary - return primary - end - - beforeAll(function() - instanceFolder = Instance.new("Folder") - instanceFolder.Name = "KnitTestFolder" - instanceFolder.Archivable = false - instanceFolder.Parent = workspace - instanceModel = Instance.new("Model") - instanceModel.Name = "KnitTestModel" - instanceModel.Archivable = false - instanceModel.Parent = workspace - end) - - afterEach(function() - instanceFolder:ClearAllChildren() - instanceModel:ClearAllChildren() - end) - - afterAll(function() - instanceFolder:Destroy() - instanceModel:Destroy() - end) - - describe("Streamable", function() - it("should detect instance that is immediately available", function() - local testInstance = CreateInstance("TestImmediate") - local streamable = Streamable.new(instanceFolder, "TestImmediate") - local observed = 0 - local cleaned = 0 - streamable:Observe(function(_instance, trove) - observed += 1 - trove:Add(function() - cleaned += 1 - end) - end) - task.wait() - testInstance.Parent = nil - task.wait() - testInstance.Parent = instanceFolder - task.wait() - streamable:Destroy() - task.wait() - expect(observed).to.equal(2) - expect(cleaned).to.equal(2) - end) - - it("should detect instance that is not immediately available", function() - local streamable = Streamable.new(instanceFolder, "TestImmediate") - local observed = 0 - local cleaned = 0 - streamable:Observe(function(_instance, trove) - observed += 1 - trove:Add(function() - cleaned += 1 - end) - end) - task.wait(0.1) - local testInstance = CreateInstance("TestImmediate") - task.wait() - testInstance.Parent = nil - task.wait() - testInstance.Parent = instanceFolder - task.wait() - streamable:Destroy() - task.wait() - expect(observed).to.equal(2) - expect(cleaned).to.equal(2) - end) - - it("should detect primary part that is immediately available", function() - local testInstance = CreatePrimary() - local streamable = Streamable.primary(instanceModel) - local observed = 0 - local cleaned = 0 - streamable:Observe(function(_instance, trove) - observed += 1 - trove:Add(function() - cleaned += 1 - end) - end) - task.wait() - testInstance.Parent = nil - task.wait() - testInstance.Parent = instanceModel - instanceModel.PrimaryPart = testInstance - task.wait() - streamable:Destroy() - task.wait() - expect(observed).to.equal(2) - expect(cleaned).to.equal(2) - end) - - it("should detect primary part that is not immediately available", function() - local streamable = Streamable.primary(instanceModel) - local observed = 0 - local cleaned = 0 - streamable:Observe(function(_instance, trove) - observed += 1 - trove:Add(function() - cleaned += 1 - end) - end) - task.wait(0.1) - local testInstance = CreatePrimary() - task.wait() - testInstance.Parent = nil - task.wait() - testInstance.Parent = instanceModel - instanceModel.PrimaryPart = testInstance - task.wait() - streamable:Destroy() - task.wait() - expect(observed).to.equal(2) - expect(cleaned).to.equal(2) - end) - end) -end diff --git a/modules/streamable/StreamableUtil.spec.luau b/modules/streamable/StreamableUtil.spec.luau deleted file mode 100644 index 00c266b3..00000000 --- a/modules/streamable/StreamableUtil.spec.luau +++ /dev/null @@ -1,60 +0,0 @@ -return function() - local Streamable = require(script.Parent.Streamable) - local StreamableUtil = require(script.Parent.StreamableUtil) - - local instanceFolder - - local function CreateInstance(name) - local folder = Instance.new("Folder") - folder.Name = name - folder.Archivable = false - folder.Parent = instanceFolder - return folder - end - - beforeAll(function() - instanceFolder = Instance.new("Folder") - instanceFolder.Name = "KnitTest" - instanceFolder.Archivable = false - instanceFolder.Parent = workspace - end) - - afterEach(function() - instanceFolder:ClearAllChildren() - end) - - afterAll(function() - instanceFolder:Destroy() - end) - - describe("Compound", function() - it("should capture multiple streams", function() - local s1 = Streamable.new(instanceFolder, "ABC") - local s2 = Streamable.new(instanceFolder, "XYZ") - local observe = 0 - local cleaned = 0 - StreamableUtil.Compound({ S1 = s1, S2 = s2 }, function(_streamables, trove) - observe += 1 - trove:Add(function() - cleaned += 1 - end) - end) - local i1 = CreateInstance("ABC") - local i2 = CreateInstance("XYZ") - task.wait() - i1.Parent = nil - task.wait() - i1.Parent = instanceFolder - task.wait() - i1.Parent = nil - i2.Parent = nil - task.wait() - i2.Parent = instanceFolder - task.wait() - expect(observe).to.equal(2) - expect(cleaned).to.equal(2) - s1:Destroy() - s2:Destroy() - end) - end) -end diff --git a/test/wally.lock b/test/wally.lock index fa176b94..346cd099 100644 --- a/test/wally.lock +++ b/test/wally.lock @@ -2,12 +2,7 @@ # It is not intended for manual editing. registry = "test" -[[package]] -name = "roblox/testez" -version = "0.4.1" -dependencies = [] - [[package]] name = "sleit/rbxutil" version = "0.1.0" -dependencies = [["TestEZ", "roblox/testez@0.4.1"]] +dependencies = []