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(C))(S,U)local w=(require(c.benchmarks.utils))(S,U)local p=(require(c.benchmarks.cases.Tree))(S,U)local l=(require(c.benchmarks.cases.SierpinskiTriangle))(S,U)local R=(require(c.testUtils.bootstrapSync))(S,U)local N=require(n.Dev.JestGlobals)local L=N.describe local m=N.it local V=N.afterEach L("\098\101\110\099\104\109\097\114\107 \097\112\112 \116\101\115\116\115",function()local C V(function()if C then C()C=nil end end)m("\115\104\111\117\108\100 \114\101\110\100\101\114",function()local c={["\077\111\117\110\116 \100\101\101\112 \116\114\101\101"]=w.createTestBlock(function(C)return{benchmarkType="\109\111\117\110\116",Component=p.Tree;getComponentProps=function()return{breadth=2;components=C;depth=7,id=0,wrap=1}end;Provider=C.Provider;sampleCount=50,anchorPoint=Vector2.new(.5,.5)}end);["\077\111\117\110\116 \119\105\100\101 \116\114\101\101"]=w.createTestBlock(function(C)return{benchmarkType="\109\111\117\110\116",Component=p.Tree,getComponentProps=function()return{breadth=6;components=C;depth=3,id=0,wrap=2}end;Provider=C.Provider,sampleCount=50;anchorPoint=Vector2.new(.5,.5)}end),["\085\112\100\097\116\101 \100\121\110\097\109\105\099 \115\116\121\108\101\115"]=w.createTestBlock(function(C)return{benchmarkType="\117\112\100\097\116\101";Component=l.SierpinskiTriangle;getComponentProps=function(c)return{components=C;s=200;renderCount=c.cycle,sampleCount=c.sampleCount;x=0;y=0}end,Provider=C.Provider,sampleCount=50;anchorPoint=Vector2.new(0,0)}end)}local n=Instance.new("\070\111\108\100\101\114")n.Name="\071\117\105\082\111\111\116"C=R(n,O,{tests=c})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 App = require(testWorkspace)(Roact, ReactRoblox)
local Utils = require(srcWorkspace.benchmarks.utils)(Roact, ReactRoblox)
local Tree = require(srcWorkspace.benchmarks.cases.Tree)(Roact, ReactRoblox)
local SierpinskiTriangle = require(srcWorkspace.benchmarks.cases.SierpinskiTriangle)(Roact, ReactRoblox)
local bootstrapSync = require(srcWorkspace.testUtils.bootstrapSync)(Roact, ReactRoblox)

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local describe = JestGlobals.describe
local it = JestGlobals.it
local afterEach = JestGlobals.afterEach

describe("benchmark app tests", function()
	local stop

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

	it("should render", function()
		local tests = {
			["Mount deep tree"] = Utils.createTestBlock(function(components)
				return {
					benchmarkType = "mount",
					Component = Tree.Tree,
					getComponentProps = function()
						return { breadth = 2, components = components, depth = 7, id = 0, wrap = 1 }
					end,
					Provider = components.Provider,
					sampleCount = 50,
					anchorPoint = Vector2.new(0.5, 0.5),
				}
			end),
			["Mount wide tree"] = Utils.createTestBlock(function(components)
				return {
					benchmarkType = "mount",
					Component = Tree.Tree,
					getComponentProps = function()
						return { breadth = 6, components = components, depth = 3, id = 0, wrap = 2 }
					end,
					Provider = components.Provider,
					sampleCount = 50,
					anchorPoint = Vector2.new(0.5, 0.5),
				}
			end),
			["Update dynamic styles"] = Utils.createTestBlock(function(components)
				return {
					benchmarkType = "update",
					Component = SierpinskiTriangle.SierpinskiTriangle,
					getComponentProps = function(props)
						return {
							components = components,
							s = 200,
							renderCount = props.cycle,
							sampleCount = props.sampleCount,
							x = 0,
							y = 0,
						}
					end,
					Provider = components.Provider,
					sampleCount = 50,
					anchorPoint = Vector2.new(0, 0),
				}
			end),
		}

		local rootInstance = Instance.new("Folder")
		rootInstance.Name = "GuiRoot"
		stop = bootstrapSync(rootInstance, App, { tests = tests })
	end)
end)
