local j local d local A=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 f=A.beforeEach local T=A.expect local Z=A.describe local O=A.it local I=A.jest Z("\082\101\097\099\116\084\101\115\116\082\101\110\100\101\114\101\114",function()f(function()I.resetModules()I.useRealTimers()j=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116-\114\111\098\108\111\120")I.resetModules()d=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")end)O("\115\104\111\117\108\100 \119\097\114\110 \105\102 \117\115\101\100 \116\111 \114\101\110\100\101\114 \097 \082\101\097\099\116\082\111\098\108\111\120 \112\111\114\116\097\108",function()local A=Instance.new("\070\111\108\100\101\114");(T(function()(T(function()d.create(j.createPortal("\102\111\111",A))end)).toThrow()end)).toErrorDev("\087\097\114\110\105\110\103\058 \065\110 \105\110\118\097\108\105\100 \099\111\110\116\097\105\110\101\114 \104\097\115 \098\101\101\110 \112\114\111\118\105\100\101\100\046",{withoutStack=true})end)end)
--[[*
 * 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
 ]]

-- 'use strict'

local ReactRoblox
local ReactTestRenderer
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
local beforeEach = JestGlobals.beforeEach
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it
local jest = JestGlobals.jest

describe("ReactTestRenderer", function()
	beforeEach(function()
		jest.resetModules()
		jest.useRealTimers()
		ReactRoblox = require("@pkg/@jsdotlua/react-roblox")

		-- Isolate test renderer.
		jest.resetModules()
		ReactTestRenderer = require("@pkg/@jsdotlua/react-test-renderer")
	end)

	it("should warn if used to render a ReactRoblox portal", function()
		local container = Instance.new("Folder")

		jestExpect(function()
			jestExpect(function()
				ReactTestRenderer.create(ReactRoblox.createPortal("foo", container))
			end).toThrow()
			-- ROBLOX deviation START: This has `Warning: ` appended to it versus upstream, wording adjusted to not mention ReactDOM
		end).toErrorDev("Warning: An invalid container has been provided.", {
			-- ROBLOX deviation END
			withoutStack = true,
		})
	end)

	-- describe('timed out Suspense hidden subtrees should not be observable via toJSON', () => {
	--   local AsyncText
	--   local PendingResources
	--   local TextResource

	--   beforeEach(() => {
	--     PendingResources = {}
	--     TextResource = ReactCache.unstable_createResource(
	--       text =>
	--         new Promise(resolve => {
	--           PendingResources[text] = resolve
	--         }),
	--       text => text,
	--     )

	--     AsyncText = ({text}) => {
	--       local value = TextResource.read(text)
	--       return value
	--     }
	--   })

	--   it('for root Suspense components', async done => {
	--     local App = ({text}) => {
	--       return (
	--         <React.Suspense fallback="fallback">
	--           <AsyncText text={text} />
	--         </React.Suspense>
	--       )
	--     }

	--     local root = ReactTestRenderer.create(<App text="initial" />)
	--     PendingResources.initial('initial')
	--     await Promise.resolve()
	--     Scheduler.unstable_flushAll()
	--     expect(root.toJSON()).toEqual('initial')

	--     root.update(<App text="dynamic" />)
	--     expect(root.toJSON()).toEqual('fallback')

	--     PendingResources.dynamic('dynamic')
	--     await Promise.resolve()
	--     Scheduler.unstable_flushAll()
	--     expect(root.toJSON()).toEqual('dynamic')

	--     done()
	--   })

	--   it('for nested Suspense components', async done => {
	--     local App = ({text}) => {
	--       return (
	--         <div>
	--           <React.Suspense fallback="fallback">
	--             <AsyncText text={text} />
	--           </React.Suspense>
	--         </div>
	--       )
	--     }

	--     local root = ReactTestRenderer.create(<App text="initial" />)
	--     PendingResources.initial('initial')
	--     await Promise.resolve()
	--     Scheduler.unstable_flushAll()
	--     expect(root.toJSON().children).toEqual(['initial'])

	--     root.update(<App text="dynamic" />)
	--     expect(root.toJSON().children).toEqual(['fallback'])

	--     PendingResources.dynamic('dynamic')
	--     await Promise.resolve()
	--     Scheduler.unstable_flushAll()
	--     expect(root.toJSON().children).toEqual(['dynamic'])

	--     done()
	--   })
	-- })
end)
