local O=script.Parent local Z=require(O.Flags)local p=require(O.Parent.Promise)local j=require(O.get)return function()describe("\103\101\116",function()local O afterEach(function()if O then O:cancel()end Z.reset()end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \097 \112\114\111\109\105\115\101",function()O=j("\102\108\097\103");(expect(O)).to.be.ok();(expect(p.is(O))).to.equal(true)end)it("\115\104\111\117\108\100 \114\101\115\111\108\118\101 \116\111 \116\104\101 \118\097\108\117\101 \111\102 \116\104\101 \102\108\097\103",function()Z.create("\102\108\097\103")O=j("\102\108\097\103")local p=(O:now()):expect();(expect(p)).to.be.ok()end)it("\115\104\111\117\108\100 \114\101\115\111\108\118\101 \119\105\116\104 \097 \102\108\097\103",function()Z.create("\102\108\097\103")O=j("\102\108\097\103")local p=(O:now()):expect();(expect(p)).to.be.ok();(expect(p.name)).to.be.a("\115\116\114\105\110\103");(expect(p.create)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.exists)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.read)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.update)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.retire)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.destroy)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.isActive)).to.be.a("\102\117\110\099\116\105\111\110");(expect(p.onChange)).to.be.a("\102\117\110\099\116\105\111\110")end)it("\115\104\111\117\108\100 \114\101\115\111\108\118\101 \119\105\116\104 \097 \102\108\097\103 \116\104\097\116 \104\097\115 \116\104\101 \099\111\114\114\101\099\116 \110\097\109\101",function()Z.create("\102\108\097\103")O=j("\102\108\097\103")local p=(O:now()):expect();(expect(p.name)).to.equal("\102\108\097\103")end)it("\115\104\111\117\108\100 \114\101\115\111\108\118\101 \119\105\116\104 \097 \102\108\097\103 \116\104\097\116 \104\097\115 \116\104\101 \099\111\114\114\101\099\116 \097\099\116\105\118\101 \115\116\097\116\101",function()Z.create("\102\108\097\103")O=j("\102\108\097\103")local p=(O:now()):expect();(expect(p.isActive())).to.equal(true)end)it("\115\104\111\117\108\100 \110\111\116 \114\101\115\111\108\118\101 \119\104\101\110 \110\111 \102\108\097\103 \101\120\105\115\116\115",function()O=j("\102\108\097\103")local Z=(O:now()):await();(expect(Z)).to.equal(false)end)it("\115\104\111\117\108\100 \110\111\116 \114\101\115\111\108\118\101 \117\110\116\105\108 \116\104\101 \102\108\097\103 \105\115 \099\114\101\097\116\101\100",function()O=j("\102\108\097\103")local p=(O:now()):await();(expect(p)).to.equal(false)Z.create("\102\108\097\103")p=(O:now()):await();(expect(p)).to.equal(true)end)end)end
local Package = script.Parent
local Flags = require(Package.Flags)
local Promise = require(Package.Parent.Promise)
local get = require(Package.get)

return function()
	describe("get", function()
		local promise

		afterEach(function()
			if promise then
				promise:cancel()
			end

			Flags.reset()
		end)

		it("should return a promise", function()
			promise = get("flag")
			expect(promise).to.be.ok()
			expect(Promise.is(promise)).to.equal(true)
		end)

		it("should resolve to the value of the flag", function()
			Flags.create("flag")
			promise = get("flag")
			local flag = promise:now():expect()

			expect(flag).to.be.ok()
		end)

		it("should resolve with a flag", function()
			Flags.create("flag")
			promise = get("flag")
			local flag = promise:now():expect()

			expect(flag).to.be.ok()
			expect(flag.name).to.be.a("string")
			expect(flag.create).to.be.a("function")
			expect(flag.exists).to.be.a("function")
			expect(flag.read).to.be.a("function")
			expect(flag.update).to.be.a("function")
			expect(flag.retire).to.be.a("function")
			expect(flag.destroy).to.be.a("function")
			expect(flag.isActive).to.be.a("function")
			expect(flag.onChange).to.be.a("function")
		end)

		it("should resolve with a flag that has the correct name", function()
			Flags.create("flag")
			promise = get("flag")
			local flag = promise:now():expect()

			expect(flag.name).to.equal("flag")
		end)

		it("should resolve with a flag that has the correct active state", function()
			Flags.create("flag")
			promise = get("flag")
			local flag = promise:now():expect()

			expect(flag.isActive()).to.equal(true)
		end)

		it("should not resolve when no flag exists", function()
			promise = get("flag")
			local resolved = promise:now():await()

			expect(resolved).to.equal(false)
		end)

		it("should not resolve until the flag is created", function()
			promise = get("flag")
			local resolved = promise:now():await()

			expect(resolved).to.equal(false)

			Flags.create("flag")
			resolved = promise:now():await()

			expect(resolved).to.equal(true)
		end)
	end)
end
