Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel committed Dec 17, 2024
1 parent 9cdfec9 commit 3577403
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Testing/newFolder.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local function newFolder(children: { [string]: Instance }): Folder
local folder = Instance.new("Folder")
folder.Name = "Root"

for name, child in pairs(children) do
child.Name = name
child.Parent = folder
end

return folder
end

return newFolder
36 changes: 36 additions & 0 deletions src/Testing/newFolder.spec.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
local JestGlobals = require("@pkg/JestGlobals")
local newFolder = require("./newFolder")

local expect = JestGlobals.expect
local test = JestGlobals.test

test("return a folder named 'Root'", function()
local folder = newFolder({})
expect(folder:IsA("Folder")).toBe(true)
expect(folder.Name).toBe("Root")
end)

test("name children after the dictionary keys", function()
local child1 = Instance.new("Part")
local child2 = Instance.new("Model")

local folder: any = newFolder({
Child1 = child1,
Child2 = child2,
})

expect(folder.Child1).toBe(child1)
expect(folder.Child2).toBe(child2)
end)

test("support nesting newFolder as children", function()
local folder: any = newFolder({
Child = newFolder({
AnotherChild = newFolder({
Module = Instance.new("ModuleScript"),
}),
}),
})

expect(folder.Child.AnotherChild.Module).toBeDefined()
end)

0 comments on commit 3577403

Please sign in to comment.