From 467621e615d813ed3b491407888b06cde4d2ce87 Mon Sep 17 00:00:00 2001 From: Stephen Leitnick Date: Tue, 10 Dec 2024 10:21:27 -0500 Subject: [PATCH] Ser test --- modules/ser/init.spec.luau | 46 ----------------------------------- modules/ser/init.test.luau | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 46 deletions(-) delete mode 100644 modules/ser/init.spec.luau create mode 100644 modules/ser/init.test.luau diff --git a/modules/ser/init.spec.luau b/modules/ser/init.spec.luau deleted file mode 100644 index c0710fea..00000000 --- a/modules/ser/init.spec.luau +++ /dev/null @@ -1,46 +0,0 @@ -return function() - local Ser = require(script.Parent) - local Option = require(script.Parent.Parent.Option) - - describe("SerializeArgs", function() - it("should serialize an option", function() - local opt = Option.Some(32) - local serOpt = table.unpack(Ser.SerializeArgs(opt)) - expect(serOpt.ClassName).to.equal("Option") - expect(serOpt.Value).to.equal(32) - end) - end) - - describe("SerializeArgsAndUnpack", function() - it("should serialize an option", function() - local opt = Option.Some(32) - local serOpt = Ser.SerializeArgsAndUnpack(opt) - expect(serOpt.ClassName).to.equal("Option") - expect(serOpt.Value).to.equal(32) - end) - end) - - describe("DeserializeArgs", function() - it("should deserialize args to option", function() - local serOpt = { - ClassName = "Option", - Value = 32, - } - local opt = table.unpack(Ser.DeserializeArgs(serOpt)) - expect(Option.Is(opt)).to.equal(true) - expect(opt:Contains(32)).to.equal(true) - end) - end) - - describe("DeserializeArgsAndUnpack", function() - it("should deserialize args to option", function() - local serOpt = { - ClassName = "Option", - Value = 32, - } - local opt = Ser.DeserializeArgsAndUnpack(serOpt) - expect(Option.Is(opt)).to.equal(true) - expect(opt:Contains(32)).to.equal(true) - end) - end) -end diff --git a/modules/ser/init.test.luau b/modules/ser/init.test.luau new file mode 100644 index 00000000..14773cb4 --- /dev/null +++ b/modules/ser/init.test.luau @@ -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