return function()local K=require(script.Parent.Parent.assertDeepEqual)local e=require(script.Parent.Parent.createElement)local B=require(script.Parent.Parent.createReconciler)local M=require(script.Parent.Parent.createSpy)local x=require(script.Parent.Parent.NoopRenderer)local u=require(script.Parent.Parent.Type)local P=require(script.Parent.Parent.Component)local J=B(x)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 B=P:extend("\077\121\067\111\109\112\111\110\101\110\116")local x=M()B.didUpdate=x.value function B.render(K)return nil end local C={a=5}local g=e(B,C)local p=nil local j="\084\101\115\116"local U=J.mountVirtualNode(g,p,j);(expect(x.callCount)).to.equal(0)local v={a=6,b=2}local r=e(B,v)J.updateVirtualNode(U,r);(expect(x.callCount)).to.equal(1)local n=x:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(u.of(n.self))).to.equal(u.StatefulComponentInstance)K(n.oldProps,C)K(n.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 B=P:extend("\077\121\067\111\109\112\111\110\101\110\116")local x=M()B.didUpdate=x.value local C={a=4}local g function B.init(K)g=function(...)return K:setState(...)end K:setState(C)end function B.render(K) end local p=e(B)local j=nil local U="\084\101\115\116"J.mountVirtualNode(p,j,U);(expect(x.callCount)).to.equal(0)g({a=5});(expect(x.callCount)).to.equal(1)local v=x:captureValues("\115\101\108\102","\111\108\100\080\114\111\112\115","\111\108\100\083\116\097\116\101");(expect(u.of(v.self))).to.equal(u.StatefulComponentInstance)K(v.oldProps,{})K(v.oldState,C)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