Files
skyweave/spec/utisl_spec.lua
T
wes 3803b21c85
Skyweave Test & Lint Ritual / Test and Lint Code (push) Successful in 23s
Going to revisit this later lol
2025-06-12 21:32:15 -04:00

39 lines
1.4 KiB
Lua
Executable File

-- This test script will verify the functions within skyweave/utils.lua
package.path = './skyweave/?.lua;' .. package.path
local utils = require("utils")
describe("Skyweave Utility Functions Module", function()
-- A nested 'describe' for the specific function we are testing.
describe("parse_query_string", function()
-- 'it' blocks contain the actual test cases.
it("should correctly parse a single key-value pair", function()
local query = "get_config=network_config"
local expected = { get_config = "network_config" }
assert.are.same(expected, utils.parse_query_string(query))
end)
it("should handle multiple parameters correctly", function()
local query = "ssid=MyWifi&encryption=psk2&channel=11"
local expected = { ssid = "MyWifi", encryption = "psk2", channel = "11" }
assert.are.same(expected, utils.parse_query_string(query))
end)
it("should handle URL-encoded characters", function()
local query = "ssid=My%20Awesome%20Wifi"
local expected = { ssid = "My Awesome Wifi" }
assert.are.same(expected, utils.parse_query_string(query))
end)
it("should return an empty table for a nil or empty query string", function()
assert.are.same({}, utils.parse_query_string(""))
assert.are.same({}, utils.parse_query_string(nil))
end)
end)
-- more 'describe' blocks here to test other functions in utils.lua
end)