local x=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\108\117\097\117-\112\111\108\121\102\105\108\108")local B=x.Error local g=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\106\101\115\116-\103\108\111\098\097\108\115")local P=g.afterEach local I=g.beforeEach local V=g.describe local K=g.expect local S=g.it local d=g.jest V("\082\101\097\099\116 \104\111\111\107\115 \068\101\118\084\111\111\108\115 \105\110\116\101\103\114\097\116\105\111\110",function()local x local g local V local A local L local U local D local o I(function()_G.__REACT_DEVTOOLS_GLOBAL_HOOK__={inject=function(x)U=x.overrideHookState D=x.scheduleUpdate o=x.setSuspenseHandler end;supportsFiber=true;onCommitFiberRoot=function() end,onCommitFiberUnmount=function() end}d.resetModules()V=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116-\116\101\115\116-\114\101\110\100\101\114\101\114")x=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116")g=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116-\100\101\098\117\103-\116\111\111\108\115")A=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\115\099\104\101\100\117\108\101\114")L=V.act end)P(function()_G.__REACT_DEVTOOLS_GLOBAL_HOOK__=nil end)S("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \101\100\105\116\105\110\103 \117\115\101\083\116\097\116\101 \104\111\111\107\115",function()local B local function P()local g,P=x.useState(0)B=P return x.createElement("\070\114\097\109\101",nil,x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\099\111\117\110\116\058"}),x.createElement("\084\101\120\116\076\097\098\101\108",{Text=tostring(g)}))end local I=V.create(x.createElement(P,nil));(K(I:toJSON())).toEqual({type="\070\114\097\109\101",props={};children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\099\111\117\110\116\058"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\048"}}}})local S=(I.root:findByType(P)):_currentFiber()local d=g.inspectHooksOfFiber(S)local A=d[1];(K(A.isStateEditable)).toBe(true)if _G.__DEV__ then U(S,A.id,{},10);(K(I:toJSON())).toEqual({type="\070\114\097\109\101",props={},children={{type="\084\101\120\116\076\097\098\101\108",props={Text="\099\111\117\110\116\058"}},{type="\084\101\120\116\076\097\098\101\108",props={Text="\049\048"}}}})L(function()return B(function(x)return x+1 end)end);(K(I:toJSON())).toEqual({type="\070\114\097\109\101";props={};children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\099\111\117\110\116\058"}},{type="\084\101\120\116\076\097\098\101\108";props={Text="\049\049"}}}})end end)S("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \101\100\105\116\097\098\108\101 \117\115\101\082\101\100\117\099\101\114 \104\111\111\107\115",function()local P={foo="\097\098\099";bar=123}local function I(x,g)local P=g.type if P=="\115\119\097\112"then return{foo=x.bar;bar=x.foo}else error(B.new())end end local S local function d()local B,g=x.useReducer(I,P)S=g return x.createElement("\070\114\097\109\101",{},x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\102\111\111\058"}),x.createElement("\084\101\120\116\076\097\098\101\108",{Text=tostring(B.foo)}),x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\044 \098\097\114\058"}),x.createElement("\084\101\120\116\076\097\098\101\108",{Text=tostring(B.bar)}))end local A=V.create(x.createElement(d,nil));(K(A:toJSON())).toEqual({type="\070\114\097\109\101",props={};children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\102\111\111\058"}},{type="\084\101\120\116\076\097\098\101\108",props={Text="\097\098\099"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\044 \098\097\114\058"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\049\050\051"}}}})local D=(A.root:findByType(d)):_currentFiber()local o=g.inspectHooksOfFiber(D)local G=o[1];(K(G.isStateEditable)).toBe(true)if _G.__DEV__ then U(D,G.id,{"\102\111\111"},"\100\101\102");(K(A:toJSON())).toEqual({type="\070\114\097\109\101",props={};children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\102\111\111\058"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\100\101\102"}},{type="\084\101\120\116\076\097\098\101\108";props={Text="\044 \098\097\114\058"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\049\050\051"}}}})L(function()return S({type="\115\119\097\112"})end);(K(A:toJSON())).toEqual({type="\070\114\097\109\101",props={},children={{type="\084\101\120\116\076\097\098\101\108",props={Text="\102\111\111\058"}};{type="\084\101\120\116\076\097\098\101\108",props={Text="\049\050\051"}};{type="\084\101\120\116\076\097\098\101\108",props={Text="\044 \098\097\114\058"}};{type="\084\101\120\116\076\097\098\101\108",props={Text="\100\101\102"}}}})end end)S("\115\104\111\117\108\100 \104\097\110\100\108\101 \105\110\116\101\114\108\101\097\118\101\100 \115\116\097\116\101\102\117\108 \104\111\111\107\115 \040\101\046\103\046 \117\115\101\083\116\097\116\101\041 \097\110\100 \110\111\110-\115\116\097\116\101\102\117\108 \104\111\111\107\115 \040\101\046\103\046 \117\115\101\067\111\110\116\101\120\116\041",function()local B=x.createContext(1)local P local function I()local g=x.useContext(B)local I,V=x.useState({count=g})x.useDebugValue(I.count)P=V return I.count end local function S()local B=I()return x.createElement("\070\114\097\109\101",nil,x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\099\111\117\110\116\058"}),x.createElement("\084\101\120\116\076\097\098\101\108",{Text=tostring(B)}))end local d=V.create(x.createElement(S,nil));(K(d:toJSON())).toEqual({type="\070\114\097\109\101",props={},children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\099\111\117\110\116\058"}},{type="\084\101\120\116\076\097\098\101\108",props={Text="\049"}}}})local A=(d.root:findByType(S)):_currentFiber()local D=g.inspectHooksOfFiber(A)local o=D[1].subHooks[2];(K(o.isStateEditable)).toBe(true)if _G.__DEV__ then U(A,o.id,{"\099\111\117\110\116"},10);(K(d:toJSON())).toEqual({type="\070\114\097\109\101",props={},children={{type="\084\101\120\116\076\097\098\101\108",props={Text="\099\111\117\110\116\058"}};{type="\084\101\120\116\076\097\098\101\108";props={Text="\049\048"}}}})L(function()return P(function(x)return{count=x.count+1}end)end);(K(d:toJSON())).toEqual({type="\070\114\097\109\101";props={},children={{type="\084\101\120\116\076\097\098\101\108";props={Text="\099\111\117\110\116\058"}},{type="\084\101\120\116\076\097\098\101\108";props={Text="\049\049"}}}})end end)S("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \111\118\101\114\114\105\100\105\110\103 \115\117\115\112\101\110\115\101 \105\110 \108\101\103\097\099\121 \109\111\100\101",function()if _G.__DEV__ then o(function()return true end)end local function B()return x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\068\111\110\101"})end local g=V.create(x.createElement("\070\114\097\109\101",nil,x.createElement(x.Suspense,{fallback=x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\076\111\097\100\105\110\103"})},x.createElement(B,nil))))local P=(g.root:_currentFiber()).child if _G.__DEV__ then(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108",props={Text="\076\111\097\100\105\110\103"}}})D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108",props={Text="\076\111\097\100\105\110\103"}}})o(function()return false end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108",props={Text="\068\111\110\101"}}})D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108",props={Text="\068\111\110\101"}}})o(function()return true end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})o(function()return false end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})o(function(x)return x==P or x==P.alternate end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})o(function(x)return x~=P and x~=P.alternate end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108",props={Text="\068\111\110\101"}}})else(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})end end)S("\115\104\111\117\108\100 \115\117\112\112\111\114\116 \111\118\101\114\114\105\100\105\110\103 \115\117\115\112\101\110\115\101 \105\110 \099\111\110\099\117\114\114\101\110\116 \109\111\100\101",function()d.useFakeTimers()if _G.__DEV__ then o(function()return true end)end local function B()return x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\068\111\110\101"})end local g=V.create(x.createElement("\100\105\118",nil,x.createElement(x.Suspense,{fallback=x.createElement("\084\101\120\116\076\097\098\101\108",{Text="\076\111\097\100\105\110\103"})},x.createElement(B,nil))),{unstable_isConcurrent=true});(K(A)).toFlushAndYield({})d.advanceTimersByTime(1000)local P=(g.root:_currentFiber()).child if _G.__DEV__ then(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})o(function()return false end)D(P)A.unstable_flushAll();(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})o(function()return true end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})o(function()return false end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})o(function(x)return x==P or x==P.alternate end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\076\111\097\100\105\110\103"}}})o(function(x)return x~=P and x~=P.alternate end)D(P);(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})else(K((g:toJSON()).children)).toEqual({{type="\084\101\120\116\076\097\098\101\108";props={Text="\068\111\110\101"}}})end d.useRealTimers()end)end)
-- ROBLOX upstream: https://github.com/facebook/react/blob/v17.0.2/packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js
--[[*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 * @jest-environment node
 ]]
local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
-- ROBLOX deviation START: not needed
-- local Boolean = LuauPolyfill.Boolean
-- ROBLOX deviation END
local Error = LuauPolyfill.Error
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
-- ROBLOX deviation START: add additional import
local afterEach = JestGlobals.afterEach
-- ROBLOX deviation END
local beforeEach = JestGlobals.beforeEach
local describe = JestGlobals.describe
local expect = JestGlobals.expect
local it = JestGlobals.it
local jest = JestGlobals.jest

describe("React hooks DevTools integration", function()
	local React
	local ReactDebugTools
	local ReactTestRenderer
	local Scheduler
	local act
	local overrideHookState
	local scheduleUpdate
	local setSuspenseHandler
	beforeEach(function()
		-- ROBLOX deviation START: use _G instead of global
		-- global.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
		_G.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
			-- ROBLOX deviation END
			inject = function(injected)
				overrideHookState = injected.overrideHookState
				scheduleUpdate = injected.scheduleUpdate
				setSuspenseHandler = injected.setSuspenseHandler
			end,
			supportsFiber = true,
			onCommitFiberRoot = function() end,
			onCommitFiberUnmount = function() end,
		}
		jest.resetModules()
		-- ROBLOX deviation START: fix requires
		-- React = require_("react")
		-- ReactDebugTools = require_("react-debug-tools")
		-- ReactTestRenderer = require_("react-test-renderer")
		-- Scheduler = require_("scheduler")
		ReactTestRenderer = require("@pkg/@jsdotlua/react-test-renderer")
		React = require("@pkg/@jsdotlua/react")
		ReactDebugTools = require("@pkg/@jsdotlua/react-debug-tools")
		Scheduler = require("@pkg/@jsdotlua/scheduler")
		-- ROBLOX deviation END
		act = ReactTestRenderer.act
	end)
	-- ROBLOX deviation START: add afterEach to revert global flag
	afterEach(function()
		_G.__REACT_DEVTOOLS_GLOBAL_HOOK__ = nil
	end)
	-- ROBLOX deviation END
	it("should support editing useState hooks", function()
		local setCountFn
		local function MyComponent()
			-- ROBLOX deviation START: useState returns 2 values
			-- local count, setCount = table.unpack(React.useState(0), 1, 2)
			local count, setCount = React.useState(0)
			-- ROBLOX deviation END
			setCountFn = setCount
			-- ROBLOX deviation START: use TextLabel instead
			-- return React.createElement("div", nil, "count:", count)
			return React.createElement(
				"Frame",
				nil,
				React.createElement("TextLabel", { Text = "count:" }),
				React.createElement("TextLabel", { Text = tostring(count) })
			)
			-- ROBLOX deviation END
		end
		local renderer = ReactTestRenderer.create(React.createElement(MyComponent, nil))
		expect(renderer:toJSON()).toEqual({
			-- ROBLOX deviation START: use Frame instead
			-- type = "div",
			type = "Frame",
			-- ROBLOX deviation END
			props = {},
			-- ROBLOX deviation START: use TextLabels instead
			-- children = { "count:", "0" },
			children = {
				{ type = "TextLabel", props = { Text = "count:" } },
				{ type = "TextLabel", props = { Text = "0" } },
			},
			-- ROBLOX deviation END
		})
		local fiber = renderer.root:findByType(MyComponent):_currentFiber()
		-- ROBLOX deviation START: use dot notation
		-- local tree = ReactDebugTools:inspectHooksOfFiber(fiber)
		local tree = ReactDebugTools.inspectHooksOfFiber(fiber)
		-- ROBLOX deviation END
		local stateHook = tree[
			1 --[[ ROBLOX adaptation: added 1 to array index ]]
		]
		expect(stateHook.isStateEditable).toBe(true)
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			overrideHookState(fiber, stateHook.id, {}, 10)
			expect(renderer:toJSON()).toEqual({
				-- ROBLOX deviation START: use Frame instead
				-- type = "div",
				type = "Frame",
				-- ROBLOX deviation END
				props = {},
				-- ROBLOX deviation START: use TextLabels instead
				-- children = { "count:", "10" },
				children = {
					{ type = "TextLabel", props = { Text = "count:" } },
					{ type = "TextLabel", props = { Text = "10" } },
				},
				-- ROBLOX deviation END
			})
			act(function()
				return setCountFn(function(count)
					return count + 1
				end)
			end)
			expect(renderer:toJSON()).toEqual({
				-- ROBLOX deviation START: use Frame instead
				-- type = "div",
				type = "Frame",
				-- ROBLOX deviation END
				props = {},
				-- ROBLOX deviation START: use TextLabels instead
				-- children = { "count:", "11" },
				children = {
					{ type = "TextLabel", props = { Text = "count:" } },
					{ type = "TextLabel", props = { Text = "11" } },
				},
				-- ROBLOX deviation END
			})
		end
	end)
	it("should support editable useReducer hooks", function()
		local initialData = { foo = "abc", bar = 123 }
		local function reducer(state, action)
			local condition_ = action.type
			if condition_ == "swap" then
				return { foo = state.bar, bar = state.foo }
			else
				error(Error.new())
			end
		end
		local dispatchFn
		local function MyComponent()
			-- ROBLOX deviation START: returns 2 values
			-- local state, dispatch =
			-- 	table.unpack(React.useReducer(reducer, initialData), 1, 2)
			-- ROBLOX deviation END
			local state, dispatch = React.useReducer(reducer, initialData)
			dispatchFn = dispatch
			-- ROBLOX deviation START: use Frame and TextLabels instead
			-- return React.createElement("div", nil, "foo:", state.foo, ", bar:", state.bar)
			return React.createElement(
				"Frame",
				{},
				React.createElement("TextLabel", { Text = "foo:" }),
				React.createElement("TextLabel", { Text = tostring(state.foo) }),
				React.createElement("TextLabel", { Text = ", bar:" }),
				React.createElement("TextLabel", { Text = tostring(state.bar) })
			)
			-- ROBLOX deviation END
		end
		local renderer = ReactTestRenderer.create(React.createElement(MyComponent, nil))
		expect(renderer:toJSON()).toEqual({
			-- ROBLOX deviation START: use Frame instead
			-- type = "div",
			type = "Frame",
			-- ROBLOX deviation END
			props = {},
			-- ROBLOX deviation START: use TextLabels instead
			-- children = { "foo:", "abc", ", bar:", "123" },
			children = {
				{ type = "TextLabel", props = { Text = "foo:" } },
				{ type = "TextLabel", props = { Text = "abc" } },
				{ type = "TextLabel", props = { Text = ", bar:" } },
				{ type = "TextLabel", props = { Text = "123" } },
			},
			-- ROBLOX deviation END
		})
		local fiber = renderer.root:findByType(MyComponent):_currentFiber()
		-- ROBLOX deviation START: use dot notation
		-- local tree = ReactDebugTools:inspectHooksOfFiber(fiber)
		local tree = ReactDebugTools.inspectHooksOfFiber(fiber)
		-- ROBLOX deviation END
		local reducerHook = tree[
			1 --[[ ROBLOX adaptation: added 1 to array index ]]
		]
		expect(reducerHook.isStateEditable).toBe(true)
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			overrideHookState(fiber, reducerHook.id, { "foo" }, "def")
			expect(renderer:toJSON()).toEqual({
				-- ROBLOX deviation START: use Frame instead
				-- type = "div",
				type = "Frame",
				-- ROBLOX deviation END
				props = {},
				-- ROBLOX deviation START: use TextLabels instead
				-- children = { "foo:", "def", ", bar:", "123" },
				children = {
					{ type = "TextLabel", props = { Text = "foo:" } },
					{ type = "TextLabel", props = { Text = "def" } },
					{ type = "TextLabel", props = { Text = ", bar:" } },
					{ type = "TextLabel", props = { Text = "123" } },
				},
				-- ROBLOX deviation END
			})
			act(function()
				return dispatchFn({ type = "swap" })
			end)
			expect(renderer:toJSON()).toEqual({
				-- ROBLOX deviation START: use Frame instead
				-- type = "div",
				type = "Frame",
				-- ROBLOX deviation END
				props = {},
				-- ROBLOX deviation START: use TextLabels instead
				-- children = { "foo:", "123", ", bar:", "def" },
				children = {
					{ type = "TextLabel", props = { Text = "foo:" } },
					{ type = "TextLabel", props = { Text = "123" } },
					{ type = "TextLabel", props = { Text = ", bar:" } },
					{ type = "TextLabel", props = { Text = "def" } },
				},
				-- ROBLOX deviation END
			})
		end
	end) -- This test case is based on an open source bug report:
	-- facebookincubator/redux-react-hook/issues/34#issuecomment-466693787
	it(
		"should handle interleaved stateful hooks (e.g. useState) and non-stateful hooks (e.g. useContext)",
		function()
			local MyContext = React.createContext(1)
			local setStateFn
			local function useCustomHook()
				local context = React.useContext(MyContext)
				-- ROBLOX deviation START: returns 2 values
				-- local state, setState =
				-- 	table.unpack(React.useState({ count = context }), 1, 2)
				local state, setState = React.useState({ count = context })
				-- ROBLOX deviation END
				React.useDebugValue(state.count)
				setStateFn = setState
				return state.count
			end
			local function MyComponent()
				local count = useCustomHook()
				-- ROBLOX deviation START: use Frame and TextLabels instead
				-- return React.createElement("div", nil, "count:", count)
				return React.createElement(
					"Frame",
					nil,
					React.createElement("TextLabel", { Text = "count:" }),
					React.createElement("TextLabel", { Text = tostring(count) })
				)
				-- ROBLOX deviation END
			end
			local renderer =
				ReactTestRenderer.create(React.createElement(MyComponent, nil))
			expect(renderer:toJSON()).toEqual({
				-- ROBLOX deviation START: use Frame instead
				-- type = "div",
				type = "Frame",
				-- ROBLOX deviation END
				props = {},
				-- ROBLOX deviation START: use TextLabels instead
				-- children = { "count:", "1" },
				children = {
					{ type = "TextLabel", props = { Text = "count:" } },
					{ type = "TextLabel", props = { Text = "1" } },
				},
				-- ROBLOX deviation END
			})
			local fiber = renderer.root:findByType(MyComponent):_currentFiber()
			-- ROBLOX deviation START: use dot notation
			-- local tree = ReactDebugTools:inspectHooksOfFiber(fiber)
			local tree = ReactDebugTools.inspectHooksOfFiber(fiber)
			-- ROBLOX deviation END
			local stateHook = tree[
				1 --[[ ROBLOX adaptation: added 1 to array index ]]
			].subHooks[
				2 --[[ ROBLOX adaptation: added 1 to array index ]]
			]
			expect(stateHook.isStateEditable).toBe(true)
			-- ROBLOX deviation START: use _G.__DEV__
			-- if Boolean.toJSBoolean(__DEV__) then
			if _G.__DEV__ then
				-- ROBLOX deviation END
				overrideHookState(fiber, stateHook.id, { "count" }, 10)
				expect(renderer:toJSON()).toEqual({
					-- ROBLOX deviation START: use Frame instead
					-- type = "div",
					type = "Frame",
					-- ROBLOX deviation END
					props = {},
					-- ROBLOX deviation START: use TextLabels instead
					-- children = { "count:", "10" },
					children = {
						{ type = "TextLabel", props = { Text = "count:" } },
						{ type = "TextLabel", props = { Text = "10" } },
					},
					-- ROBLOX deviation END
				})
				act(function()
					return setStateFn(function(state)
						return { count = state.count + 1 }
					end)
				end)
				expect(renderer:toJSON()).toEqual({
					-- ROBLOX deviation START: use Frame instead
					-- type = "div",
					type = "Frame",
					-- ROBLOX deviation END
					props = {},
					-- ROBLOX deviation START: use TextLabels instead
					-- children = { "count:", "11" },
					children = {
						{ type = "TextLabel", props = { Text = "count:" } },
						{ type = "TextLabel", props = { Text = "11" } },
					},
					-- ROBLOX deviation END
				})
			end
		end
	)
	it("should support overriding suspense in legacy mode", function()
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			-- Lock the first render
			setSuspenseHandler(function()
				return true
			end)
		end
		local function MyComponent()
			-- ROBLOX deviation START: use TextLabel instead
			-- return "Done"
			return React.createElement("TextLabel", { Text = "Done" })
			-- ROBLOX deviation END
		end
		local renderer = ReactTestRenderer.create(React.createElement(
			-- ROBLOX deviation START: use Frame instead
			-- "div",
			"Frame",
			-- ROBLOX deviation END
			nil,
			React.createElement(
				React.Suspense,
				-- ROBLOX deviation START: use TextLabel instead
				-- { fallback = "Loading" },
				{ fallback = React.createElement("TextLabel", { Text = "Loading" }) },
				-- ROBLOX deviation END
				React.createElement(MyComponent, nil)
			)
		))
		local fiber = renderer.root:_currentFiber().child
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			-- First render was locked
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" }) -- Release the lock
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return false
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" }) -- Lock again
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return true
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" }) -- Release the lock again
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return false
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" }) -- Ensure it checks specific fibers.
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function(f)
				return f == fiber or f == fiber.alternate
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function(f)
				return f ~= fiber and f ~= fiber.alternate
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
		else
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
		end
	end)
	it("should support overriding suspense in concurrent mode", function()
		-- ROBLOX deviation START: add useFakeTimers
		jest.useFakeTimers()
		-- ROBLOX deviation END
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			-- Lock the first render
			setSuspenseHandler(function()
				return true
			end)
		end
		local function MyComponent()
			-- ROBLOX deviation START: use TextLabel instead
			-- return "Done"
			return React.createElement("TextLabel", { Text = "Done" })
			-- ROBLOX deviation END
		end
		local renderer = ReactTestRenderer.create(
			React.createElement(
				"div",
				nil,
				React.createElement(
					React.Suspense,
					-- ROBLOX deviation START: use TextLabel instead
					-- { fallback = "Loading" },
					{ fallback = React.createElement("TextLabel", { Text = "Loading" }) },
					-- ROBLOX deviation END
					React.createElement(MyComponent, nil)
				)
			),
			{ unstable_isConcurrent = true }
		)
		expect(Scheduler).toFlushAndYield({}) -- Ensure we timeout any suspense time.
		jest.advanceTimersByTime(1000)
		local fiber = renderer.root:_currentFiber().child
		-- ROBLOX deviation START: use _G.__DEV__
		-- if Boolean.toJSBoolean(__DEV__) then
		if _G.__DEV__ then
			-- ROBLOX deviation END
			-- First render was locked
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" }) -- Release the lock
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return false
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use dot notation
			-- Scheduler:unstable_flushAll()
			Scheduler.unstable_flushAll()
			-- ROBLOX deviation END
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" }) -- Lock again
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return true
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" }) -- Release the lock again
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function()
				return false
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" }) -- Ensure it checks specific fibers.
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function(f)
				return f == fiber or f == fiber.alternate
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Loading" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Loading" },
				},
			})
			-- ROBLOX deviation END
			setSuspenseHandler(function(f)
				return f ~= fiber and f ~= fiber.alternate
			end)
			scheduleUpdate(fiber) -- Re-render
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
			-- ROBLOX deviation END
		else
			-- ROBLOX deviation START: use TextLabel instead
			-- expect(renderer:toJSON().children).toEqual({ "Done" })
			expect(renderer:toJSON().children).toEqual({
				{
					type = "TextLabel",
					props = { Text = "Done" },
				},
			})
		end
		-- ROBLOX deviation START: add useRealTimers
		jest.useRealTimers()
		-- ROBLOX deviation END
	end)
end)
