local U=import("\046\047\099\114\101\097\116\101\083\101\116\116\105\110\103\115")local N=import("\046\047\102\117\110\099\116\105\111\110\115\047\116\121\112\101\111\102")describe("\102\117\110\099\116\105\111\110\115\046\115\101\116\116\105\110\103\115",function()it("\115\104\111\117\108\100 \098\101 \097 \102\117\110\099\116\105\111\110",function()assert.is_function(U)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \097\099\116\117\097\108 \115\101\116\116\105\110\103\115\040\041 \102\117\110\099\116\105\111\110",function()local N=U({})local P=N()assert.equals(type(P),"\117\115\101\114\100\097\116\097")end)it("\115\104\111\117\108\100 \097\108\119\097\121\115 \114\101\116\117\114\110 \116\104\101 \115\097\109\101 \111\098\106\101\099\116",function()local N=U({})local P=N()local F=N()assert.equals(P,F)end)describe("\071\101\116\070\070\108\097\103",function()it("\115\104\111\117\108\100 \099\104\101\099\107 \102\097\115\116 \102\108\097\103\115",function()local N=U({flags={FFTest=true,FFTest2=true;FFDoesSomethingHappen=false}})local P=N()assert.True(P:GetFFlag("\070\070\084\101\115\116"))assert.True(P:GetFFlag("\070\070\084\101\115\116\050"))assert.False(P:GetFFlag("\070\070\068\111\101\115\083\111\109\101\116\104\105\110\103\072\097\112\112\101\110"))end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \097 \102\097\115\116 \102\108\097\103 \100\111\101\115 \110\111\116 \101\120\105\115\116",function()local N=U({flags={FFTest=true;FFTest2=true,FFDoesSomethingHappen=false}})local P=N()assert.has.errors(function()P:GetFFlag("\070\070\085\110\100\101\102\105\110\101\100\070\097\115\116\070\108\097\103")end)end)end)it("\115\104\111\117\108\100 \104\097\118\101 \097 \112\114\111\112\101\114\116\121 \082\101\110\100\101\114\105\110\103",function()local P=U({})local F=P()local s=F.Rendering assert.not_nil(s)assert.equals(N(s),"\082\101\110\100\101\114\083\101\116\116\105\110\103\115")end)it("\115\104\111\117\108\100 \110\111\116 \097\108\108\111\119 \109\101 \116\111 \115\101\116 \116\104\101 \082\101\110\100\101\114\105\110\103 \112\114\111\112\101\114\116\121",function()local N=U({})local P=N()assert.has.errors(function()P.Rendering=true end)end)it("\115\104\111\117\108\100 \110\111\116 \097\108\108\111\119 \109\101 \116\111 \097\099\099\101\115\115 \117\110\100\101\102\105\110\101\100 \112\114\111\112\101\114\116\105\101\115",function()local N=U({})local P=N()assert.has.errors(function()tostring(P.thisDoesNotExist)end)end)it("\115\104\111\117\108\100 \110\111\116 \097\108\108\111\119 \109\101 \116\111 \115\101\116 \117\110\100\101\102\105\110\101\100 \112\114\111\112\101\114\116\105\101\115",function()local N=U({})local P=N()assert.has.errors(function()P.thisDoesNotExist="\116\104\105\115 \115\104\111\117\108\100 \116\104\114\111\119"end)end)end)
local createSettings = import("./createSettings")
local typeof = import("./functions/typeof")

describe("functions.settings", function()
	it("should be a function", function()
		assert.is_function(createSettings)
	end)

	it("should return the actual settings() function", function()
		local settings = createSettings({})
		local instance = settings()
		assert.equals(type(instance), "userdata")
	end)

	it("should always return the same object", function()
		local settings = createSettings({})

		local instance = settings()
		local instance2 = settings()
		assert.equals(instance, instance2)
	end)

	describe("GetFFlag", function()
		it("should check fast flags", function()
			local settings = createSettings({
				flags = {
					FFTest = true,
					FFTest2 = true,
					FFDoesSomethingHappen = false,
				}
			})

			local instance = settings()
			assert.True(instance:GetFFlag("FFTest"))
			assert.True(instance:GetFFlag("FFTest2"))
			assert.False(instance:GetFFlag("FFDoesSomethingHappen"))
		end)

		it("should throw if a fast flag does not exist", function()
			local settings = createSettings({
				flags = {
					FFTest = true,
					FFTest2 = true,
					FFDoesSomethingHappen = false,
				}
			})
			local instance = settings()

			assert.has.errors(function()
				instance:GetFFlag("FFUndefinedFastFlag")
			end)
		end)
	end)

	it("should have a property Rendering", function()
		local settings = createSettings({})

		local instance = settings()
		local renderSettings = instance.Rendering

		assert.not_nil(renderSettings)
		assert.equals(typeof(renderSettings), "RenderSettings")
	end)

	it("should not allow me to set the Rendering property", function()
		local settings = createSettings({})

		local instance = settings()
		assert.has.errors(function()
			instance.Rendering = true
		end)
	end)

	it("should not allow me to access undefined properties", function()
		local settings = createSettings({})

		local instance = settings()
		assert.has.errors(function()
			tostring(instance.thisDoesNotExist)
		end)
	end)

	it("should not allow me to set undefined properties", function()
		local settings = createSettings({})

		local instance = settings()
		assert.has.errors(function()
			instance.thisDoesNotExist = "this should throw"
		end)
	end)
end)
