local w=require(script.Parent.Parent.Util.BasicallyIdentical)return function()local u=require(script.Parent)describe("\116\111\072\101\120\040\046\046\046\041",function()it("\116\104\114\111\119\115 \105\102 \097\114\103\117\109\101\110\116 \105\115 \110\111\116 \097 \067\111\108\111\114\051",function()(expect(pcall(u.toHex,true))).to.equal(false)end)it("\099\111\110\118\101\114\116\115 \097 \067\111\108\111\114\051 \116\111 \104\101\120",function()(expect(u.toHex(Color3.fromRGB(0,162,255)))).to.equal("\048\048\097\050\102\102")end)end)describe("\102\114\111\109\072\101\120\040\046\046\046\041",function()it("\116\104\114\111\119\115 \105\102 \097\114\103\117\109\101\110\116 \105\115 \110\111\116 \097 \115\116\114\105\110\103",function()(expect(pcall(u.fromHex,true))).to.equal(false)end)it("\099\111\110\118\101\114\116\115 \097 \115\116\097\110\100\097\114\100 \054-\099\104\097\114\097\099\116\101\114 \104\101\120 \099\111\100\101 \116\111 \067\111\108\111\114\051",function()(expect(w(Color3.fromRGB(0,162,255),u.fromHex("\035\048\048\065\050\070\070")))).to.equal(true)end)it("\099\111\110\118\101\114\116\115 \097 \051-\099\104\097\114\097\099\116\101\114 \104\101\120 \099\111\100\101 \116\111 \067\111\108\111\114\051",function()(expect(w(Color3.fromRGB(170,51,221),u.fromHex("\035\097\051\100")))).to.equal(true)end)it("\099\111\110\118\101\114\116\115 \105\114\114\101\103\117\108\097\114 \104\101\120 \099\111\100\101\115 \116\111 \067\111\108\111\114\051",function()(expect(w(Color3.new(1,1,1),u.fromHex("\035\102")))).to.equal(true);(expect(w(Color3.fromRGB(158,158,158),u.fromHex("\035\057\101")))).to.equal(true)end)it("\114\101\116\117\114\110\115 \"\098\108\097\099\107\" \105\102 \097\114\103\117\109\101\110\116 \105\115 \097\110 \101\109\112\116\121 \115\116\114\105\110\103",function()(expect(w(Color3.new(),u.fromHex("")))).to.equal(true)end)end)describe("\102\114\111\109\072\101\120\082\071\066\065\040\046\046\046\041",function()it("\116\104\114\111\119\115 \105\102 \097\114\103\117\109\101\110\116 \105\115 \110\111\116 \097 \115\116\114\105\110\103",function()(expect(pcall(u.fromHexRGBA,true))).to.equal(false)end)it("\099\111\110\118\101\114\116\115 \097\110 \097\108\112\104\097 \104\101\120 \099\111\100\101 \116\111 \067\111\108\111\114\051",function()(expect(w(Color3.fromHex("\035\056\048\056\048\056\048"),u.fromHexRGBA("\035\070\070\070\070\070\070\056\048")))).to.equal(true);(expect(w(Color3.fromHex("\035\056\048\068\049\070\070"),u.fromHexRGBA("\035\048\048\065\050\070\070\056\048",Color3.new(1,1,1))))).to.equal(true);(expect(w(Color3.fromHex("\035\048\048\053\049\056\048"),u.fromHexRGBA("\035\048\048\065\050\070\070\056\048")))).to.equal(true);(expect(w(Color3.fromHex("\035\048\048\065\050\070\070"),u.fromHexRGBA("\035\048\048\065\050\070\070\048\048")))).to.equal(true);(expect(w(Color3.new(),u.fromHexRGBA("\035\048\048\065\050\070\070\070\070")))).to.equal(true)end)end)end
local BasicallyIdentical = require(script.Parent.Parent.Util.BasicallyIdentical)

return function()
	local Hex = require(script.Parent)

	describe("toHex(...)", function()
		it("throws if argument is not a Color3", function()
			expect(pcall(Hex.toHex, true)).to.equal(false)
		end)

		it("converts a Color3 to hex", function()
			expect(Hex.toHex(Color3.fromRGB(0, 162, 255))).to.equal("00a2ff")
		end)
	end)

	describe("fromHex(...)", function()
		it("throws if argument is not a string", function()
			expect(pcall(Hex.fromHex, true)).to.equal(false)
		end)

		it("converts a standard 6-character hex code to Color3", function()
			expect(BasicallyIdentical(Color3.fromRGB(0, 162, 255), Hex.fromHex("#00A2FF"))).to.equal(true)
		end)

		it("converts a 3-character hex code to Color3", function()
			expect(BasicallyIdentical(Color3.fromRGB(170, 51, 221), Hex.fromHex("#a3d"))).to.equal(true)
		end)

		it("converts irregular hex codes to Color3", function()
			expect(BasicallyIdentical(Color3.new(1, 1, 1), Hex.fromHex("#f"))).to.equal(true)
			expect(BasicallyIdentical(Color3.fromRGB(158, 158, 158), Hex.fromHex("#9e"))).to.equal(true)
		end)

		it('returns "black" if argument is an empty string', function()
			expect(BasicallyIdentical(Color3.new(), Hex.fromHex(""))).to.equal(true)
		end)
	end)

	describe("fromHexRGBA(...)", function()
		it("throws if argument is not a string", function()
			expect(pcall(Hex.fromHexRGBA, true)).to.equal(false)
		end)

		it("converts an alpha hex code to Color3", function()
			-- white fg, transparency 50%, black bg
			expect(BasicallyIdentical(Color3.fromHex("#808080"), Hex.fromHexRGBA("#FFFFFF80"))).to.equal(true)

			-- blue fg, transparency 50%, white bg
			expect(BasicallyIdentical(Color3.fromHex("#80D1FF"), Hex.fromHexRGBA("#00A2FF80", Color3.new(1, 1, 1)))).to.equal(
				true
			)

			-- blue fg, transparency 50%, black bg
			expect(BasicallyIdentical(Color3.fromHex("#005180"), Hex.fromHexRGBA("#00A2FF80"))).to.equal(true)

			-- blue fg, transparency 0%, black bg
			expect(BasicallyIdentical(Color3.fromHex("#00A2FF"), Hex.fromHexRGBA("#00A2FF00"))).to.equal(true)

			-- blue fg, transparency 100%, black bg
			expect(BasicallyIdentical(Color3.new(), Hex.fromHexRGBA("#00A2FFFF"))).to.equal(true)
		end)
	end)
end
