diff --git a/default.project.json b/default.project.json index 115bbd24..697bef28 100644 --- a/default.project.json +++ b/default.project.json @@ -1,13 +1,7 @@ - { - "name": "Satchel", - "tree": { - "$className": "DataModel", - "StarterPlayer": { - "$className": "StarterPlayer", - "StarterPlayerScripts": { - "$className": "StarterPlayerScripts", - "$path": "src" - } - } - } +{ + "name": "Satchel", + "globIgnorePaths": ["**/*.spec.lua"], + "tree": { + "$path": "src" } +} diff --git a/develop.project.json b/develop.project.json new file mode 100644 index 00000000..46560213 --- /dev/null +++ b/develop.project.json @@ -0,0 +1,19 @@ +{ + "name": "Satchel", + "globIgnorePaths": ["**/*.spec.lua"], + "tree": { + "$className": "DataModel", + "StarterPlayer": { + "$className": "StarterPlayer", + "StarterPlayerScripts": { + "$className": "StarterPlayerScripts", + "Develop": { + "$path": "tests/Develop.client.lua", + "Satchel": { + "$path": "src" + } + } + } + } + } +} diff --git a/selene.toml b/selene.toml index 1f1e1703..c1911beb 100644 --- a/selene.toml +++ b/selene.toml @@ -1 +1 @@ -std = "roblox" \ No newline at end of file +std = "roblox+testez" \ No newline at end of file diff --git a/src/Satchel/Packages.project.json b/src/Packages.project.json similarity index 58% rename from src/Satchel/Packages.project.json rename to src/Packages.project.json index f2fe542e..80cb8ff7 100644 --- a/src/Satchel/Packages.project.json +++ b/src/Packages.project.json @@ -1,6 +1,6 @@ { "name": "Packages", "tree": { - "$path": "../../Packages" + "$path": "../Packages" } } diff --git a/src/Satchel/SatchelScript.lua b/src/init.lua similarity index 99% rename from src/Satchel/SatchelScript.lua rename to src/init.lua index 3fe77878..e74e7daa 100644 --- a/src/Satchel/SatchelScript.lua +++ b/src/init.lua @@ -1,7 +1,7 @@ --!strict --[[ - Name: SatchelScript + Name: Satchel Version: 1.2.0 Description: Satchel is a modern open-source alternative to Roblox's default backpack. Satchel aims to be more customizable and easier to use than the default backpack while still having a "vanilla" feel. By: @WinnersTakesAll on Roblox & @RyanLua on GitHub @@ -153,7 +153,7 @@ local GAMEPAD_INPUT_TYPES: { [Enum.UserInputType]: boolean } = -- Topbar logic local BackpackEnabled: boolean = true -local UIShelf: any = require(script.Parent.Packages.UIShelf) +local UIShelf: any = require(script.Packages.UIShelf) local BackpackGui: ScreenGui = Instance.new("ScreenGui") BackpackGui.DisplayOrder = 120 diff --git a/src/Satchel/init.meta.json b/src/init.meta.json similarity index 100% rename from src/Satchel/init.meta.json rename to src/init.meta.json diff --git a/src/init.spec.lua b/src/init.spec.lua new file mode 100644 index 00000000..91b8a20f --- /dev/null +++ b/src/init.spec.lua @@ -0,0 +1,44 @@ +return function() + local Satchel = require(script.Parent) + + it("SetBackpackEnabled(false)", function() + Satchel:SetBackpackEnabled(false) + expect(Satchel:GetBackpackEnabled()).to.equal(false) + end) + it("SetBackpackEnabled(true)", function() + Satchel:SetBackpackEnabled(true) + expect(Satchel:GetBackpackEnabled()).to.equal(true) + end) + it("GetBackpackEnabled", function() + local getBackpackEnabled = Satchel:GetBackpackEnabled() + expect(getBackpackEnabled).to.be.a("boolean") + end) + it("IsOpened", function() + local isOpened = Satchel:IsOpened() + expect(isOpened).to.be.a("boolean") + end) + it("GetStateChangedEvent", function() + local getStateChangedEvent = Satchel:GetStateChangedEvent() + expect(getStateChangedEvent).to.be.a("userdata") + end) + it("OpenClose", function() + local openClose = Satchel.OpenClose + expect(openClose).to.be.a("function") + end) + it("StateChanged", function() + local stateChanged = Satchel.StateChanged + expect(stateChanged).to.be.a("userdata") + end) + it("BackpackEmpty", function() + local backpackEmpty = Satchel.BackpackEmpty + expect(backpackEmpty).to.be.a("userdata") + end) + it("BackpackItemAdded", function() + local backpackItemAdded = Satchel.BackpackItemAdded + expect(backpackItemAdded).to.be.a("userdata") + end) + it("BackpackItemRemoved", function() + local backpackItemRemoved = Satchel.BackpackItemRemoved + expect(backpackItemRemoved).to.be.a("userdata") + end) +end diff --git a/test.project.json b/test.project.json new file mode 100644 index 00000000..3c2eb106 --- /dev/null +++ b/test.project.json @@ -0,0 +1,22 @@ +{ + "name": "Satchel", + "tree": { + "$className": "DataModel", + "ReplicatedStorage": { + "$className": "ReplicatedStorage", + "$path": "Packages" + }, + "StarterPlayer": { + "$className": "StarterPlayer", + "StarterPlayerScripts": { + "$className": "StarterPlayerScripts", + "Test": { + "$path": "tests/Test.client.lua", + "Satchel": { + "$path": "src" + } + } + } + } + } +} diff --git a/testez.yml b/testez.yml new file mode 100644 index 00000000..5c1addae --- /dev/null +++ b/testez.yml @@ -0,0 +1,53 @@ +--- +globals: + FIXME: + args: + - required: false + type: string + FOCUS: + args: [] + SKIP: + args: [] + afterAll: + args: + - type: function + afterEach: + args: + - type: function + beforeAll: + args: + - type: function + beforeEach: + args: + - type: function + describe: + args: + - type: string + - type: function + describeFOCUS: + args: + - type: string + - type: function + describeSKIP: + args: + - type: string + - type: function + expect: + args: + - type: any + it: + args: + - type: string + - type: function + itFIXME: + args: + - type: string + - type: function + itFOCUS: + args: + - type: string + - type: function + itSKIP: + args: + - type: string + - type: function \ No newline at end of file diff --git a/src/Satchel/init.client.lua b/tests/Develop.client.lua similarity index 82% rename from src/Satchel/init.client.lua rename to tests/Develop.client.lua index e36cb076..5de357cd 100644 --- a/src/Satchel/init.client.lua +++ b/tests/Develop.client.lua @@ -10,4 +10,4 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. ]] -require(script:WaitForChild("SatchelScript")) -- Initialize Satchel +require(script:WaitForChild("Satchel")) -- Initialize Satchel diff --git a/tests/Test.client.lua b/tests/Test.client.lua new file mode 100644 index 00000000..75f7a719 --- /dev/null +++ b/tests/Test.client.lua @@ -0,0 +1,18 @@ +--[[ + Name: Satchel + Description: Loads the Satchel backpack system. + GitHub: https://github.com/RyanLua/Satchel +]] + +--[[ + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. +]] +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local TestEZ = require(ReplicatedStorage:WaitForChild("testez")) + +local Satchel = script:WaitForChild("Satchel") + +require(Satchel) -- Initialize Satchel +TestEZ.TestBootstrap:run({ Satchel }) -- Run Tests diff --git a/wally.lock b/wally.lock index 863a610f..092d1099 100644 --- a/wally.lock +++ b/wally.lock @@ -22,7 +22,12 @@ name = "red-blox/spawn" version = "1.0.0" dependencies = [] +[[package]] +name = "roblox/testez" +version = "0.4.1" +dependencies = [] + [[package]] name = "ryanlua/satchel" version = "1.2.0" -dependencies = [["UIShelf", "canary-development/uishelf@1.1.5"]] +dependencies = [["UIShelf", "canary-development/uishelf@1.1.5"], ["testez", "roblox/testez@0.4.1"]] diff --git a/wally.toml b/wally.toml index 19b8b2a2..2e2a7ff0 100644 --- a/wally.toml +++ b/wally.toml @@ -10,4 +10,5 @@ exclude = ["**"] include = ["src", "src/*", "default.project.json", "wally.lock", "wally.toml"] [dependencies] -UIShelf = "canary-development/uishelf@1.1.5" \ No newline at end of file +UIShelf = "canary-development/uishelf@1.1.5" +testez = "roblox/testez@0.4.1" \ No newline at end of file