local e local k local p local f=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 S=f.expect local A=f.beforeEach local M=f.it local O=f.jest local X=f.describe X("\082\101\097\099\116\084\111\112\076\101\118\101\108\084\101\120\116",function()A(function()O.resetModules()e=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116")k=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116-\110\111\111\112-\114\101\110\100\101\114\101\114")p=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")end)M("\115\104\111\117\108\100 \114\101\110\100\101\114 \097 \099\111\109\112\111\110\101\110\116 \114\101\116\117\114\110\105\110\103 \115\116\114\105\110\103\115 \100\105\114\101\099\116\108\121 \102\114\111\109 \114\101\110\100\101\114",function()local f=function(e)return e.value end k.render(e.createElement(f,{value="\102\111\111"}));(S(p)).toFlushWithoutYielding();(S(k)).toMatchRenderedOutput("\102\111\111")end)M("\115\104\111\117\108\100 \114\101\110\100\101\114 \097 \099\111\109\112\111\110\101\110\116 \114\101\116\117\114\110\105\110\103 \110\117\109\098\101\114\115 \100\105\114\101\099\116\108\121 \102\114\111\109 \114\101\110\100\101\114\195\159",function()local f=function(e)return e.value end k.render(e.createElement(f,{value=10}));(S(p)).toFlushWithoutYielding();(S(k)).toMatchRenderedOutput("\049\048")end)end)
-- ROBLOX upstream: https://github.com/facebook/react/blob/69060e1da6061af845162dcf6854a5d9af28350a/packages/react-reconciler/src/__tests__/ReactTopLevelText-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
]]
--!strict

local React
local ReactNoop
local Scheduler

-- This is a new feature in Fiber so I put it in its own test file. It could
-- probably move to one of the other test files once it is official.
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
local jestExpect = JestGlobals.expect
local beforeEach = JestGlobals.beforeEach
local it = JestGlobals.it
local jest = JestGlobals.jest
local describe = JestGlobals.describe

describe("ReactTopLevelText", function()
	beforeEach(function()
		jest.resetModules()

		React = require("@pkg/@jsdotlua/react")
		ReactNoop = require("@pkg/@jsdotlua/react-noop-renderer")
		Scheduler = require("@pkg/@jsdotlua/scheduler")
	end)

	it("should render a component returning strings directly from render", function()
		local Text = function(props)
			return props.value
		end
		ReactNoop.render(React.createElement(Text, { value = "foo" }))
		jestExpect(Scheduler).toFlushWithoutYielding()

		jestExpect(ReactNoop).toMatchRenderedOutput("foo")
	end)

	it("should render a component returning numbers directly from renderß", function()
		local Text = function(props)
			return props.value
		end
		ReactNoop.render(React.createElement(Text, { value = 10 }))
		jestExpect(Scheduler).toFlushWithoutYielding()

		jestExpect(ReactNoop).toMatchRenderedOutput("10")
	end)
end)
