Skip to content

Commit

Permalink
Ser test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick committed Dec 10, 2024
1 parent a6a7fe7 commit 467621e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
46 changes: 0 additions & 46 deletions modules/ser/init.spec.luau

This file was deleted.

50 changes: 50 additions & 0 deletions modules/ser/init.test.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local ServerScriptService = game:GetService("ServerScriptService")

local Test = require(ServerScriptService.TestRunner.Test)

return function(ctx: Test.TestContext)
local Option = require(script.Parent.Parent.Option)
local Ser = require(script.Parent)

ctx:Describe("SerializeArgs", function()
ctx:Test("should serialize an option", function()
local opt = Option.Some(32)
local serOpt = table.unpack(Ser.SerializeArgs(opt))
ctx:Expect(serOpt.ClassName):ToBe("Option")
ctx:Expect(serOpt.Value):ToBe(32)
end)
end)

ctx:Describe("SerializeArgsAndUnpack", function()
ctx:Test("should serialize an option", function()
local opt = Option.Some(32)
local serOpt = Ser.SerializeArgsAndUnpack(opt)
ctx:Expect(serOpt.ClassName):ToBe("Option")
ctx:Expect(serOpt.Value):ToBe(32)
end)
end)

ctx:Describe("DeserializeArgs", function()
ctx:Test("should deserialize args to option", function()
local serOpt = {
ClassName = "Option",
Value = 32,
}
local opt = table.unpack(Ser.DeserializeArgs(serOpt))
ctx:Expect(Option.Is(opt)):ToBe(true)
ctx:Expect(opt:Contains(32)):ToBe(true)
end)
end)

ctx:Describe("DeserializeArgsAndUnpack", function()
ctx:Test("should deserialize args to option", function()
local serOpt = {
ClassName = "Option",
Value = 32,
}
local opt = Ser.DeserializeArgsAndUnpack(serOpt)
ctx:Expect(Option.Is(opt)):ToBe(true)
ctx:Expect(opt:Contains(32)):ToBe(true)
end)
end)
end

0 comments on commit 467621e

Please sign in to comment.