mirror of
https://github.com/lune-org/lune.git
synced 2025-04-13 23:10:52 +01:00
Add tests for Content
This commit is contained in:
parent
2956e1c45c
commit
13574d44a6
2 changed files with 52 additions and 0 deletions
|
@ -167,6 +167,7 @@ create_tests! {
|
|||
roblox_datatype_color3: "roblox/datatypes/Color3",
|
||||
roblox_datatype_color_sequence: "roblox/datatypes/ColorSequence",
|
||||
roblox_datatype_color_sequence_keypoint: "roblox/datatypes/ColorSequenceKeypoint",
|
||||
roblox_datatype_content: "roblox/datatypes/Content",
|
||||
roblox_datatype_enum: "roblox/datatypes/Enum",
|
||||
roblox_datatype_faces: "roblox/datatypes/Faces",
|
||||
roblox_datatype_font: "roblox/datatypes/Font",
|
||||
|
|
51
tests/roblox/datatypes/Content.luau
Normal file
51
tests/roblox/datatypes/Content.luau
Normal file
|
@ -0,0 +1,51 @@
|
|||
local roblox = require("@lune/roblox") :: any
|
||||
local Content = roblox.Content
|
||||
local Instance = roblox.Instance
|
||||
local Enum = roblox.Enum
|
||||
|
||||
assert(Content.none, "Content.none did not exist")
|
||||
assert(
|
||||
Content.none.SourceType == Enum.ContentSourceType.None,
|
||||
"Content.none's SourceType was wrong"
|
||||
)
|
||||
assert(Content.none.Uri == nil, "Content.none's Uri field was wrong")
|
||||
assert(Content.none.Object == nil, "Content.none's Object field was wrong")
|
||||
|
||||
local uri = Content.fromUri("test uri")
|
||||
assert(uri.SourceType == Enum.ContentSourceType.Uri, "URI Content's SourceType was wrong")
|
||||
assert(uri.Uri == "test uri", "URI Content's Uri field was wrong")
|
||||
assert(uri.Object == nil, "URI Content's Object field was wrong")
|
||||
|
||||
assert(not pcall(Content.fromUri), "Content.fromUri accepted no argument")
|
||||
assert(not pcall(Content.fromUri, false), "Content.fromUri accepted a boolean argument")
|
||||
assert(not pcall(Content.fromUri, Enum), "Content.fromUri accepted a UserData as an argument")
|
||||
assert(
|
||||
not pcall(Content.fromUri, buffer.create(0), "Content.fromUri accepted a buffer as an argument")
|
||||
)
|
||||
|
||||
-- It feels weird that this is allowed because `EditableImage` is very much
|
||||
-- not an Instance. But what can you do?
|
||||
local target = Instance.new("EditableImage")
|
||||
local object = Content.fromObject(target)
|
||||
assert(object.SourceType == Enum.ContentSourceType.Object, "Object Content's SourceType was wrong")
|
||||
assert(object.Uri == nil, "Object Content's Uri field was wrong")
|
||||
assert(object.Object == target, "Object Content's Object field was wrong")
|
||||
|
||||
assert(not pcall(Content.fromObject), "Content.fromObject accepted no argument")
|
||||
assert(not pcall(Content.fromObject, false), "Content.fromObject accepted a boolean argument")
|
||||
assert(
|
||||
not pcall(Content.fromObject, Enum),
|
||||
"Content.fromObject accepted a non-Instance/Object UserData as an argument"
|
||||
)
|
||||
assert(
|
||||
not pcall(
|
||||
Content.fromObject,
|
||||
buffer.create(0),
|
||||
"Content.fromObject accepted a buffer as an argument"
|
||||
)
|
||||
)
|
||||
|
||||
assert(
|
||||
not pcall(Content.fromObject, Instance.new("Folder")),
|
||||
"Content.fromObject accepted an Instance as an argument"
|
||||
)
|
Loading…
Add table
Reference in a new issue