local x=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=x.afterEach local F=x.beforeEach local z=x.expect local W=x.describe local M=x.it local S=x.jest local p W("\112\114\111\100\117\099\116\105\111\110 \109\111\100\101",function()local x F(function()x=_G.__ROACT_17_MOCK_SCHEDULER__ _G.__ROACT_17_MOCK_SCHEDULER__=nil S.resetModules()p=require("\046\046")end)M("\100\105\115\097\108\108\111\119\115 \117\115\101 \111\102 \'\097\099\116\'",function()S.resetModules()p=require("\046\046");(z(function()p.act(function()p.mount(p.createElement("\084\101\120\116\076\097\098\101\108"))end)end)).toThrow("\082\101\097\099\116\082\111\098\108\111\120\046\097\099\116 \105\115 \111\110\108\121 \097\118\097\105\108\097\098\108\101 \105\110 \116\101\115\116\105\110\103 \101\110\118\105\114\111\110\109\101\110\116\115\044 \110\111\116 \112\114\111\100\117\099\116\105\111\110\046 \069\110\097\098\108\101 \116\104\101 \096\095\095\082\079\065\067\084\095\049\055\095\077\079\067\075\095\083\067\072\069\068\085\076\069\082\095\095\096 \103\108\111\098\097\108 \105\110 \121\111\117\114 \116\101\115\116 \099\111\110\102\105\103\117\114\097\116\105\111\110 \105\110 \111\114\100\101\114 \116\111 \117\115\101 \096\097\099\116\096\046")end)s(function()_G.__ROACT_17_MOCK_SCHEDULER__=x end)end)W("\116\101\115\116 \109\111\100\101",function()local x F(function()x=_G.__ROACT_17_MOCK_SCHEDULER__ _G.__ROACT_17_MOCK_SCHEDULER__=true S.resetModules()p=require("\046\046")end)M("\097\108\108\111\119\115 \117\115\101 \111\102 \'\097\099\116\'",function()S.resetModules()p=require("\046\046")local x=Instance.new("\070\111\108\100\101\114")local s;(z(function()(z(function()p.act(function()s=p.mount(p.createElement("\084\101\120\116\076\097\098\101\108"),x)end)end)).toWarnDev("\'\109\111\117\110\116\' \105\115 \100\101\112\114\101\099\097\116\101\100",{withoutStack=true})end)).never.toThrow();(z(x:FindFirstChildWhichIsA("\084\101\120\116\076\097\098\101\108"))).toBeDefined();(z(function()(z(function()p.act(function()p.unmount(s)end)end)).toWarnDev("\'\117\110\109\111\117\110\116\' \105\115 \100\101\112\114\101\099\097\116\101\100",{withoutStack=true})end)).never.toThrow();(z(x:FindFirstChildWhichIsA("\084\101\120\116\076\097\098\101\108"))).toBeNil()end)s(function()_G.__ROACT_17_MOCK_SCHEDULER__=x end)end)
--[[
	* Copyright (c) Roblox Corporation. All rights reserved.
	* Licensed under the MIT License (the "License");
	* you may not use this file except in compliance with the License.
	* You may obtain a copy of the License at
	*
	*     https://opensource.org/licenses/MIT
	*
	* Unless required by applicable law or agreed to in writing, software
	* distributed under the License is distributed on an "AS IS" BASIS,
	* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	* See the License for the specific language governing permissions and
	* limitations under the License.
]]

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

describe("production mode", function()
	local prevMockScheduler
	beforeEach(function()
		prevMockScheduler = _G.__ROACT_17_MOCK_SCHEDULER__
		_G.__ROACT_17_MOCK_SCHEDULER__ = nil
		jest.resetModules()
		RoactCompat = require("..")
	end)

	it("disallows use of 'act'", function()
		jest.resetModules()
		RoactCompat = require("..")

		jestExpect(function()
			RoactCompat.act(function()
				RoactCompat.mount(RoactCompat.createElement("TextLabel"))
			end)
		end).toThrow(
			"ReactRoblox.act is only available in testing environments, "
				.. "not production. Enable the `__ROACT_17_MOCK_SCHEDULER__` "
				.. "global in your test configuration in order to use `act`."
		)
	end)

	afterEach(function()
		_G.__ROACT_17_MOCK_SCHEDULER__ = prevMockScheduler
	end)
end)

describe("test mode", function()
	local prevMockScheduler
	beforeEach(function()
		prevMockScheduler = _G.__ROACT_17_MOCK_SCHEDULER__
		_G.__ROACT_17_MOCK_SCHEDULER__ = true
		jest.resetModules()
		RoactCompat = require("..")
	end)

	it("allows use of 'act'", function()
		jest.resetModules()
		RoactCompat = require("..")

		local parent = Instance.new("Folder")
		local tree
		jestExpect(function()
			jestExpect(function()
				RoactCompat.act(function()
					tree =
						RoactCompat.mount(RoactCompat.createElement("TextLabel"), parent)
				end)
			end).toWarnDev("'mount' is deprecated", { withoutStack = true })
		end).never.toThrow()

		jestExpect(parent:FindFirstChildWhichIsA("TextLabel")).toBeDefined()
		jestExpect(function()
			jestExpect(function()
				RoactCompat.act(function()
					RoactCompat.unmount(tree)
				end)
			end).toWarnDev("'unmount' is deprecated", { withoutStack = true })
		end).never.toThrow()

		jestExpect(parent:FindFirstChildWhichIsA("TextLabel")).toBeNil()
	end)

	afterEach(function()
		_G.__ROACT_17_MOCK_SCHEDULER__ = prevMockScheduler
	end)
end)
