local I=script.Parent.Parent local p=I.Parent local l=p.Parent local t=require(l.Dev.JestGlobals)local o=t.expect local b=t.describe local q=t.it local Y=require(l.Dev.Roact)local S=require(l.Dev.ReactRoblox)local X=Y.useRef local W=(require(I.Canvas))(Y)local v=(require(p.testUtils.bootstrapSync))(Y,S)b("\067\111\110\099\117\114\114\101\110\116 \101\120\097\109\112\108\101 \116\101\115\116\115",function()local I local p q("\115\104\111\117\108\100 \112\097\115\115 \114\101\102 \116\111 \067\097\110\118\097\115",function()I=Instance.new("\070\111\108\100\101\114")I.Name="\071\117\105\082\111\111\116"local l p=v(I,function()l=X()return Y.createElement(W,{ref=l})end);(o(l.current)).toBeDefined();(o(l.current:isA("\067\097\109\101\114\097"))).toBe(true)end)q("\115\104\111\117\108\100 \097\116\116\097\099\104 \067\097\109\101\114\097 \116\111 \086\105\101\119\112\111\114\116\070\114\097\109\101",function()I=Instance.new("\070\111\108\100\101\114")I.Name="\071\117\105\082\111\111\116"local l p=v(I,function()l=X()return Y.createElement(W,{ref=l})end)local t=I:findFirstChildWhichIsA("\086\105\101\119\112\111\114\116\070\114\097\109\101")wait();(o(t)).toBeDefined();(o(t.CurrentCamera)).toBeDefined();(o(t.CurrentCamera)).toBe(l.current)end)end)
local testWorkspace = script.Parent.Parent
local srcWorkspace = testWorkspace.Parent
local rootWorkspace = srcWorkspace.Parent

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it

local Roact = require(rootWorkspace.Dev.Roact)
local ReactRoblox = require(rootWorkspace.Dev.ReactRoblox)
local useRef = Roact.useRef

local Canvas = require(testWorkspace.Canvas)(Roact)
local bootstrapSync = require(srcWorkspace.testUtils.bootstrapSync)(Roact, ReactRoblox)

describe("Concurrent example tests", function()
	local rootInstance
	local _stop

	it("should pass ref to Canvas", function()
		rootInstance = Instance.new("Folder")
		rootInstance.Name = "GuiRoot"
		local cameraRef

		_stop = bootstrapSync(rootInstance, function()
			cameraRef = useRef()
			return Roact.createElement(Canvas, {
				ref = cameraRef,
			})
		end)

		jestExpect(cameraRef.current).toBeDefined()
		jestExpect(cameraRef.current:isA("Camera")).toBe(true)
	end)

	it("should attach Camera to ViewportFrame", function()
		rootInstance = Instance.new("Folder")
		rootInstance.Name = "GuiRoot"
		local cameraRef

		_stop = bootstrapSync(rootInstance, function()
			cameraRef = useRef()
			return Roact.createElement(Canvas, {
				ref = cameraRef,
			})
		end)

		local viewPortFrame = rootInstance:findFirstChildWhichIsA("ViewportFrame")

		wait()

		jestExpect(viewPortFrame).toBeDefined()
		jestExpect(viewPortFrame.CurrentCamera).toBeDefined()
		jestExpect(viewPortFrame.CurrentCamera).toBe(cameraRef.current)
	end)
end)
