local H=script.Parent.Parent.Parent local T=require(H.JestGlobals)local R=T.expect local a=T.test local U=require(H.React)local h=(require(script.Parent.Parent)).render a("\114\101\114\101\110\100\101\114 \119\105\108\108 \114\101-\114\101\110\100\101\114 \116\104\101 \101\108\101\109\101\110\116",function()local function H(H)return U.createElement("\084\101\120\116\076\097\098\101\108",{Text=H.message})end local T=h(U.createElement(H,{message="\104\105"}))local a,t=T.container,T.rerender;(R((a:GetChildren())[1])).toHaveTextContent("\104\105")t(U.createElement(H,{message="\104\101\121"}));(R((a:GetChildren())[1])).toHaveTextContent("\104\101\121")end)return{}
-- ROBLOX upstream: https://github.com/testing-library/react-testing-library/blob/v12.1.5/src/__tests__/rerender.js
local Packages = script.Parent.Parent.Parent

local JestGlobals = require(Packages.JestGlobals)
local expect = JestGlobals.expect
local test = JestGlobals.test

local React = require(Packages.React)
local render = require(script.Parent.Parent).render

test("rerender will re-render the element", function()
	local function Greeting(props)
		return React.createElement("TextLabel", { Text = props.message })
	end
	local ref = render(React.createElement(Greeting, { message = "hi" }))
	local container, rerender = ref.container, ref.rerender
	-- ROBLOX deviation START: replace firstChild with Instance equivalent
	expect(container:GetChildren()[1]).toHaveTextContent("hi")
	rerender(React.createElement(Greeting, { message = "hey" }))
	expect(container:GetChildren()[1]).toHaveTextContent("hey")
	-- ROBLOX deviation END
end)

-- ROBLOX deviation START: hydrate not supported
-- it("hydrate will not update props until next render", function()
-- 	local initialInputElement = document:createElement("input")
-- 	local container = document:createElement("div")
-- 	container:appendChild(initialInputElement)
-- 	document.body:appendChild(container)
-- 	local firstValue = "hello"
-- 	initialInputElement.value = firstValue
-- 	local rerender = render(
-- 		React.createElement("input", {
-- 			value = "",
-- 			onChange = function()
-- 				return nil
-- 			end,
-- 		}),
-- 		{ container = container, hydrate = true }
-- 	).rerender
-- 	expect(initialInputElement).toHaveValue(firstValue)
-- 	local secondValue = "goodbye"
-- 	rerender(React.createElement("input", {
-- 		value = secondValue,
-- 		onChange = function()
-- 			return nil
-- 		end,
-- 	}))
-- 	expect(initialInputElement).toHaveValue(secondValue)
-- end)
-- ROBLOX deviation END
return {}
