local c=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 H=c.beforeEach local e=c.expect local n=c.describe local v=c.it local Q local R local function b() end local f=function() end H(function()Q=require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\114\101\097\099\116")R=(require("\064\112\107\103\047\064\106\115\100\111\116\108\117\097\047\115\104\097\114\101\100")).getComponentName end)n("\102\117\110\099\116\105\111\110 \099\111\109\112\111\110\101\110\116\115",function()v("\103\101\116\115 \110\097\109\101 \102\114\111\109 \110\111\110-\097\110\111\110\121\109\111\117\115 \102\117\110\099\116\105\111\110",function()(e(R(b))).toBe("\077\121\067\111\109\112\111\110\101\110\116")end)v("\103\101\116\115 \110\105\108 \102\114\111\109 \097\110\111\110\121\109\111\117\115 \102\117\110\099\116\105\111\110",function()local c=function() end;(e(R(c))).toBe(nil)end)end)n("\076\097\122\121 \099\111\109\112\111\110\101\110\116\115",function()v("\103\101\116\115 \110\097\109\101 \102\114\111\109 \108\097\122\121-\119\114\097\112\112\101\100 \110\111\110-\097\110\111\110\121\109\111\117\115 \102\117\110\099\116\105\111\110",function()local c=Q.lazy(function()return{andThen=function(c,H)H({default=b})end}end);(e(R(c))).toBe("\077\121\067\111\109\112\111\110\101\110\116")end)v("\103\101\116\115 \110\105\108 \102\114\111\109 \108\097\122\121-\119\114\097\112\112\101\100 \097\110\111\110\121\109\111\117\115 \102\117\110\099\116\105\111\110",function()local c=Q.lazy(function()return{andThen=function(c,H)H({default=f})end}end);(e(R(c))).toBe(nil)end)end)
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
local beforeEach = JestGlobals.beforeEach
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it
local React

local getComponentName
local function MyComponent() end
local anonymous = function() end

beforeEach(function()
	React = require("@pkg/@jsdotlua/react")

	getComponentName = require("@pkg/@jsdotlua/shared").getComponentName
end)

describe("function components", function()
	it("gets name from non-anonymous function", function()
		jestExpect(getComponentName(MyComponent)).toBe("MyComponent")
	end)
	it("gets nil from anonymous function", function()
		local anonymous = function() end
		jestExpect(getComponentName(anonymous)).toBe(nil)
	end)
end)
describe("Lazy components", function()
	it("gets name from lazy-wrapped non-anonymous function", function()
		local lazyMyComponent = React.lazy(function()
			return {
				andThen = function(self, resolve)
					resolve({ default = MyComponent })
				end,
			}
		end)
		jestExpect(getComponentName(lazyMyComponent)).toBe("MyComponent")
	end)
	it("gets nil from lazy-wrapped anonymous function", function()
		local lazyAnonymous = React.lazy(function()
			return {
				andThen = function(self, resolve)
					resolve({ default = anonymous })
				end,
			}
		end)
		jestExpect(getComponentName(lazyAnonymous)).toBe(nil)
	end)
end)
