2023-05-20 18:49:37 +01:00
|
|
|
local roblox = require("@lune/roblox")
|
2023-03-22 08:39:26 +00:00
|
|
|
local Instance = roblox.Instance
|
|
|
|
|
|
|
|
-- Should not allow creating unknown classes
|
|
|
|
assert(not pcall(function()
|
|
|
|
Instance.new("asdf")
|
|
|
|
end))
|
|
|
|
|
|
|
|
-- Should be case sensitive
|
|
|
|
assert(not pcall(function()
|
|
|
|
Instance.new("part")
|
|
|
|
end))
|
|
|
|
|
|
|
|
-- Should allow "not creatable" tagged classes to be created
|
|
|
|
Instance.new("BasePart")
|
|
|
|
|
|
|
|
-- Should have correct classnames
|
|
|
|
assert(Instance.new("Part").ClassName == "Part")
|
|
|
|
assert(Instance.new("Folder").ClassName == "Folder")
|
|
|
|
assert(Instance.new("ReplicatedStorage").ClassName == "ReplicatedStorage")
|
|
|
|
|
|
|
|
-- Should have initial names that are the same as the class name
|
|
|
|
assert(Instance.new("Part").Name == "Part")
|
|
|
|
assert(Instance.new("Folder").Name == "Folder")
|
|
|
|
assert(Instance.new("ReplicatedStorage").Name == "ReplicatedStorage")
|
|
|
|
|
|
|
|
-- Parent should be nil until parented
|
|
|
|
local folder = Instance.new("Folder")
|
|
|
|
local model = Instance.new("Model")
|
|
|
|
assert(folder.Parent == nil)
|
|
|
|
assert(model.Parent == nil)
|
|
|
|
|
|
|
|
-- Parenting and indexing should work
|
|
|
|
model.Parent = folder
|
|
|
|
assert(model.Parent == folder)
|
2023-05-20 18:49:37 +01:00
|
|
|
assert((folder :: any).Model == model)
|
2023-03-22 08:39:26 +00:00
|
|
|
|
|
|
|
-- Parenting to nil should work
|
|
|
|
model.Parent = nil
|
|
|
|
assert(model.Parent == nil)
|
|
|
|
|
|
|
|
-- Name should be able to be set, and should not be nillable
|
|
|
|
model.Name = "MyCoolModel"
|
|
|
|
assert(model.Name == "MyCoolModel")
|
|
|
|
assert(not pcall(function()
|
2023-05-20 18:49:37 +01:00
|
|
|
model.Name = nil :: any
|
2023-03-22 08:39:26 +00:00
|
|
|
end))
|
|
|
|
assert(model.Name == "MyCoolModel")
|