return function()local Y=require(script.Parent.Parent.assertDeepEqual)local i=require(script.Parent.Parent.createElement)local h=require(script.Parent.Parent.createReconciler)local x=require(script.Parent.Parent.createSpy)local C=require(script.Parent.Parent.NoopRenderer)local P=require(script.Parent.Parent.Type)local R=require(script.Parent.Parent.Component)local K=h(C)it("\115\104\111\117\108\100 \098\101 \105\110\118\111\107\101\100 \119\104\101\110 \117\112\100\097\116\101\100 \118\105\097 \117\112\100\097\116\101\086\105\114\116\117\097\108\078\111\100\101",function()local h=R:extend("\077\121\067\111\109\112\111\110\101\110\116")local C=x()h.didUpdate=C.value function h.render(Y)return nil end local A={a=5}local q=i(h,A)local k=nil local H="\084\101\115\116"local D=K.mountVirtualNode(q,k,H);(expect(C.callCount)).to.equal(0)local N={a=6;b=2}local Z=i(h,N)K.updateVirtualNode(D,Z);(expect(C.callCount)).to.equal(1)local J=C:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(P.of(J.self))).to.equal(P.StatefulComponentInstance)Y(J.oldProps,A)Y(J.oldState,{})end)it("\115\104\111\117\108\100 \098\101 \105\110\118\111\107\101\100 \119\104\101\110 \117\112\100\097\116\101\100 \118\105\097 \115\101\116\083\116\097\116\101",function()local h=R:extend("\077\121\067\111\109\112\111\110\101\110\116")local C=x()h.didUpdate=C.value local A={a=4}local q function h.init(Y)q=function(...)return Y:setState(...)end Y:setState(A)end function h.render(Y) end local k=i(h)local H=nil local D="\084\101\115\116"K.mountVirtualNode(k,H,D);(expect(C.callCount)).to.equal(0)q({a=5});(expect(C.callCount)).to.equal(1)local N=C:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(P.of(N.self))).to.equal(P.StatefulComponentInstance)Y(N.oldProps,{})Y(N.oldState,A)end)end
return function()
	local assertDeepEqual = require(script.Parent.Parent.assertDeepEqual)
	local createElement = require(script.Parent.Parent.createElement)
	local createReconciler = require(script.Parent.Parent.createReconciler)
	local createSpy = require(script.Parent.Parent.createSpy)
	local NoopRenderer = require(script.Parent.Parent.NoopRenderer)
	local Type = require(script.Parent.Parent.Type)

	local Component = require(script.Parent.Parent.Component)

	local noopReconciler = createReconciler(NoopRenderer)

	it("should be invoked when updated via updateVirtualNode", function()
		local MyComponent = Component:extend("MyComponent")

		local didUpdateSpy = createSpy()
		MyComponent.didUpdate = didUpdateSpy.value

		function MyComponent:render()
			return nil
		end

		local initialProps = {
			a = 5,
		}
		local initialElement = createElement(MyComponent, initialProps)
		local hostParent = nil
		local key = "Test"

		local virtualNode = noopReconciler.mountVirtualNode(initialElement, hostParent, key)

		expect(didUpdateSpy.callCount).to.equal(0)

		local newProps = {
			a = 6,
			b = 2,
		}
		local newElement = createElement(MyComponent, newProps)
		noopReconciler.updateVirtualNode(virtualNode, newElement)

		expect(didUpdateSpy.callCount).to.equal(1)

		local values = didUpdateSpy:captureValues("self", "oldProps", "oldState")

		expect(Type.of(values.self)).to.equal(Type.StatefulComponentInstance)
		assertDeepEqual(values.oldProps, initialProps)
		assertDeepEqual(values.oldState, {})
	end)

	it("should be invoked when updated via setState", function()
		local MyComponent = Component:extend("MyComponent")

		local didUpdateSpy = createSpy()
		MyComponent.didUpdate = didUpdateSpy.value

		local initialState = {
			a = 4,
		}

		local setState
		function MyComponent:init()
			setState = function(...)
				return self:setState(...)
			end

			self:setState(initialState)
		end

		function MyComponent:render() end

		local element = createElement(MyComponent)
		local hostParent = nil
		local key = "Test"

		noopReconciler.mountVirtualNode(element, hostParent, key)

		expect(didUpdateSpy.callCount).to.equal(0)

		setState({
			a = 5,
		})

		expect(didUpdateSpy.callCount).to.equal(1)

		local values = didUpdateSpy:captureValues("self", "oldProps", "oldState")

		expect(Type.of(values.self)).to.equal(Type.StatefulComponentInstance)
		assertDeepEqual(values.oldProps, {})
		assertDeepEqual(values.oldState, initialState)
	end)
end
