Skip to content

Commit

Permalink
Update tests to use Roact.mount and Roact.unmount.
Browse files Browse the repository at this point in the history
Fixes #8.
  • Loading branch information
LPGhatguy committed May 15, 2018
1 parent e4878eb commit d22dc52
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/StoreProvider.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ return function()

expect(element).to.be.ok()

local handle = Roact.reify(element, nil, "StoreProvider-test")
local handle = Roact.mount(element, nil, "StoreProvider-test")

Roact.teardown(handle)
Roact.unmount(handle)
store:destruct()
end)

it("should expect a 'store' prop", function()
local element = Roact.createElement(StoreProvider)

expect(function()
Roact.reify(element)
Roact.mount(element)
end).to.throw()
end)
end
6 changes: 3 additions & 3 deletions lib/connect.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ return function()
Child = Roact.createElement(ConnectedSomeComponent),
})

local handle = Roact.reify(tree)
local handle = Roact.mount(tree)

expect(handle).to.be.ok()
end)
Expand All @@ -60,7 +60,7 @@ return function()
local tree = Roact.createElement(ConnectedSomeComponent)

expect(function()
Roact.reify(tree)
Roact.mount(tree)
end).to.throw()
end)

Expand All @@ -87,7 +87,7 @@ return function()
Child = Roact.createElement(ConnectedSomeComponent),
})

Roact.reify(tree)
Roact.mount(tree)

-- Our component should render initially
expect(store:getState()).to.equal(0)
Expand Down
22 changes: 11 additions & 11 deletions lib/connect2.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ return function()
local ConnectedSomeComponent = connect2()(NoopComponent)

expect(function()
Roact.reify(Roact.createElement(ConnectedSomeComponent))
Roact.mount(Roact.createElement(ConnectedSomeComponent))
end).to.throw()
end)

Expand All @@ -82,9 +82,9 @@ return function()
someComponent = Roact.createElement(ConnectedSomeComponent),
})

local handle = Roact.reify(tree)
local handle = Roact.mount(tree)

Roact.teardown(handle)
Roact.unmount(handle)
end)

it("should not accept a higher-order mapStateToProps that returns a non-table value", function()
Expand All @@ -104,7 +104,7 @@ return function()
})

expect(function()
Roact.reify(tree)
Roact.mount(tree)
end).to.throw()
end)

Expand All @@ -123,7 +123,7 @@ return function()
})

expect(function()
Roact.reify(tree)
Roact.mount(tree)
end).to.throw()
end)

Expand All @@ -148,7 +148,7 @@ return function()
someComponent = Roact.createElement(ConnectedSomeComponent),
})

local handle = Roact.reify(tree)
local handle = Roact.mount(tree)

expect(renderCount).to.equal(1)

Expand All @@ -162,7 +162,7 @@ return function()

expect(renderCount).to.equal(2)

Roact.teardown(handle)
Roact.unmount(handle)
end)

it("should only call mapDispatchToProps once and never re-render if no mapStateToProps was passed", function()
Expand Down Expand Up @@ -191,7 +191,7 @@ return function()
someComponent = Roact.createElement(ConnectedSomeComponent),
})

local handle = Roact.reify(tree)
local handle = Roact.mount(tree)

expect(dispatchCount).to.equal(1)
expect(renderCount).to.equal(1)
Expand All @@ -208,7 +208,7 @@ return function()
expect(dispatchCount).to.equal(1)
expect(renderCount).to.equal(1)

Roact.teardown(handle)
Roact.unmount(handle)
end)

it("should return result values from the dispatch passed to mapDispatchToProps", function()
Expand Down Expand Up @@ -241,11 +241,11 @@ return function()
someComponent = Roact.createElement(ConnectedSomeComponent)
})

local handle = Roact.reify(tree)
local handle = Roact.mount(tree)

expect(dispatch).to.be.a("function")
expect(dispatch(fiveThunk)).to.equal(5)

Roact.teardown(handle)
Roact.unmount(handle)
end)
end

0 comments on commit d22dc52

Please sign in to comment.