return function()local o=require(script.Parent.Parent.assertDeepEqual)local h=require(script.Parent.Parent.createElement)local c=require(script.Parent.Parent.createReconciler)local C=require(script.Parent.Parent.createSpy)local W=require(script.Parent.Parent.NoopRenderer)local Z=require(script.Parent.Parent.Type)local v=require(script.Parent.Parent.Component)local j=c(W)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 c=v:extend("\077\121\067\111\109\112\111\110\101\110\116")local W=C()c.didUpdate=W.value function c.render(o)return nil end local m={a=5}local s=h(c,m)local Q=nil local U="\084\101\115\116"local K=j.mountVirtualNode(s,Q,U);(expect(W.callCount)).to.equal(0)local H={a=6;b=2}local S=h(c,H)j.updateVirtualNode(K,S);(expect(W.callCount)).to.equal(1)local E=W:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(Z.of(E.self))).to.equal(Z.StatefulComponentInstance)o(E.oldProps,m)o(E.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 c=v:extend("\077\121\067\111\109\112\111\110\101\110\116")local W=C()c.didUpdate=W.value local m={a=4}local s function c.init(o)s=function(...)return o:setState(...)end o:setState(m)end function c.render(o) end local Q=h(c)local U=nil local K="\084\101\115\116"j.mountVirtualNode(Q,U,K);(expect(W.callCount)).to.equal(0)s({a=5});(expect(W.callCount)).to.equal(1)local H=W:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(Z.of(H.self))).to.equal(Z.StatefulComponentInstance)o(H.oldProps,{})o(H.oldState,m)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
