local d=import("\046\047\072\116\116\112\083\101\114\118\105\099\101")describe("\105\110\115\116\097\110\099\101\115\046\072\116\116\112\083\101\114\118\105\099\101",function()it("\115\104\111\117\108\100 \105\110\115\116\097\110\116\105\097\116\101",function()local D=d:new()assert.not_nil(D)end)it("\115\104\111\117\108\100 \106\115\111\110 \101\110\099\111\100\101 \112\114\111\112\101\114\108\121",function()local D=d:new()assert.equal(D:JSONEncode({1;true}),"\091\049\044\116\114\117\101\093")end)it("\115\104\111\117\108\100 \106\115\111\110 \100\101\099\111\100\101 \112\114\111\112\101\114\108\121",function()local D=d:new()assert.are.same(D:JSONDecode("\091\049\044\116\114\117\101\093"),{1,true})end)it("\115\104\111\117\108\100 \085\082\076 \101\110\099\111\100\101 \112\114\111\112\101\114\108\121",function()local D=d:new()assert.equal(D:UrlEncode("\116\101\115\116\105\110\103 \116\101\115\116\038\116\101\115\116 \033\064\035\036\037\094\038\042\040\041\043\095-\061~\096\060\062\044\046\047\063\124 \070\114\097\110\195\167\111\105\115"),"\116\101\115\116\105\110\103\037\050\048\116\101\115\116\037\050\054\116\101\115\116\037\050\048\037\050\049\037\052\048\037\050\051\037\050\052\037\050\053\037\053\069\037\050\054\037\050\065\037\050\056\037\050\057\037\050\066\037\053\070\037\050\068\037\051\068\037\055\069\037\054\048\037\051\067\037\051\069\037\050\067\037\050\069\037\050\070\037\051\070\037\055\067\037\050\048\070\114\097\110\037\067\051\037\065\055\111\105\115")end)describe("\071\101\110\101\114\097\116\101\071\085\073\068",function()it("\115\104\111\117\108\100 \111\109\105\116 \099\117\114\108\121 \098\114\097\099\101\115 \119\104\101\110 \119\114\097\112\073\110\067\117\114\108\121\066\114\097\099\101\115 \105\115 \102\097\108\115\101",function()local D=d:new()local R=D:GenerateGUID(false)assert.equal(R:find("\123"),nil)assert.equal(R:find("\125"),nil)end)it("\115\104\111\117\108\100 \105\110\099\108\117\100\101 \099\117\114\108\121 \098\114\097\099\101\115 \119\104\101\110 \119\114\097\112\073\110\067\117\114\108\121\066\114\097\099\101\115 \105\115 \110\105\108 \111\114 \116\114\117\101",function()local D=d:new()local R=D:GenerateGUID(true)assert.equal(R:find("\123\046\043\125"),1)R=D:GenerateGUID()assert.equal(R:find("\123\046\043\125"),1)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \119\104\101\110 \103\105\118\101\110 \105\110\118\097\108\105\100 \097\114\103 \116\121\112\101\115",function()local D=d:new()assert.has_error(function()D:GenerateGUID(newproxy())end)assert.has_error(function()D:GenerateGUID({})end)assert.has_error(function()D:GenerateGUID(function() end)end)end)end)end)
local HttpService = import("./HttpService")

describe("instances.HttpService", function()
	it("should instantiate", function()
		local instance = HttpService:new()

		assert.not_nil(instance)
	end)

	it("should json encode properly", function()
		local instance = HttpService:new()

		assert.equal(instance:JSONEncode({ 1, true }), "[1,true]")
	end)

	it("should json decode properly", function()
		local instance = HttpService:new()

		assert.are.same(instance:JSONDecode("[1,true]"), { 1, true })
	end)

	it("should URL encode properly", function()
		local instance = HttpService:new()

		assert.equal(instance:UrlEncode("testing test&test !@#$%^&*()+" ..
			"_-=~`<>,./?| François"),
			"testing%20test%26test%20%21%40%23%24%25%5E%26%2A%28%29" ..
			"%2B%5F%2D%3D%7E%60%3C%3E%2C%2E%2F%3F%7C%20Fran%C3%A7ois")
	end)

	describe("GenerateGUID", function()
		it("should omit curly braces when wrapInCurlyBraces is false", function()
			local instance = HttpService:new()
			local guid = instance:GenerateGUID(false)

			assert.equal(guid:find("{"), nil)
			assert.equal(guid:find("}"), nil)
		end)

		it("should include curly braces when wrapInCurlyBraces is nil or true", function()
			local instance = HttpService:new()
			local guid = instance:GenerateGUID(true)

			assert.equal(guid:find("{.+}"), 1)

			guid = instance:GenerateGUID()

			assert.equal(guid:find("{.+}"), 1)
		end)

		it("should throw when given invalid arg types", function()
			local instance = HttpService:new()

			assert.has_error(function() instance:GenerateGUID(newproxy()) end)
			assert.has_error(function() instance:GenerateGUID({}) end)
			assert.has_error(function() instance:GenerateGUID(function() end) end)
		end)
	end)
end)