local C=script.Parent.Parent local c=C.Parent.Parent local n=c.Parent local S=require(n.Dev.Roact)local U=require(n.Dev.ReactRoblox)local O=require(n.Dev.JestGlobals)local w=O.expect local p=O.describe local l=O.it local R=O.afterEach local N=require(n.LuauPolyfill)local L=N.Array local m=N.String local V=((require(C.Tree))(S,U)).Tree local f=(require(c.testUtils.bootstrapSync))(S,U)local v=(require(c.benchmarks.implementations.roact))(S,U)p("\116\114\101\101 \098\101\110\099\104\109\097\114\107 \099\097\115\101 \116\101\115\116\115 \040\114\111\097\099\116\041",function()local C R(function()if C then C()C=nil end end)l("\115\104\111\117\108\100 \114\101\110\100\101\114 \119\105\116\104 \099\104\105\108\100\114\101\110 \109\097\116\099\104\105\110\103 \099\111\110\102\105\103\117\114\101\100 \098\114\101\097\100\116\104",function()local c={breadth=2;components=v,depth=7;id=0,wrap=0}local n=Instance.new("\070\111\108\100\101\114")n.Name="\071\117\105\082\111\111\116"C=f(n,V,c)local S=(n:GetChildren())[1]local U=S:GetChildren()local O=#L.filter(U,function(C)return m.startsWith(C.Name,"\105\100 \061 ")end);(w(O)).toBe(c.breadth)end)end)
local testWorkspace = script.Parent.Parent
local srcWorkspace = testWorkspace.Parent.Parent
local rootWorkspace = srcWorkspace.Parent

local Roact = require(rootWorkspace.Dev.Roact)
local ReactRoblox = require(rootWorkspace.Dev.ReactRoblox)
local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it
local afterEach = JestGlobals.afterEach
local LuauPolyfill = require(rootWorkspace.LuauPolyfill)
local Array = LuauPolyfill.Array
local String = LuauPolyfill.String

local Tree = require(testWorkspace.Tree)(Roact, ReactRoblox).Tree
local bootstrapSync = require(srcWorkspace.testUtils.bootstrapSync)(Roact, ReactRoblox)
local components = require(srcWorkspace.benchmarks.implementations.roact)(Roact, ReactRoblox)

describe("tree benchmark case tests (roact)", function()
	local stop

	afterEach(function()
		if stop then
			stop()
			stop = nil
		end
	end)

	it("should render with children matching configured breadth", function()
		local props = {
			breadth = 2,
			components = components,
			depth = 7,
			id = 0,
			wrap = 0,
		}

		local rootInstance = Instance.new("Folder")
		rootInstance.Name = "GuiRoot"
		stop = bootstrapSync(rootInstance, Tree, props)

		local treeRoot = rootInstance:GetChildren()[1]
		local children = treeRoot:GetChildren()
		local count = #Array.filter(children, function(item)
			return String.startsWith(item.Name, "id = ")
		end)

		jestExpect(count).toBe(props.breadth)
	end)
end)
