-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |