-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test logic in calls onResize when parent has been resized
gives false positive
#9
Comments
Good question! |
Can it be the spy cache? I'm not on my computer now so can't check. |
Seems that the culprit is the |
Seems that the calls to it('calls onResize when parent has been resized', (done) => {
const resizeSpy = spy(ContainerDimensions.prototype, 'onResize')
const logResizeCount = (msg) => console.log(msg, resizeSpy.callCount)
logResizeCount('before mount') // 0
const wrapper = mount(
<div ref="node" id="node" style={{ width: 10 }}>
<ContainerDimensions>
<MyComponent />
</ContainerDimensions>
</div>
)
logResizeCount('after mount') // 1
const el = wrapper.render()
el.css('width', 10)
logResizeCount('after first resize') // 1
setTimeout(() => {
el.css('width', 100) // Triggering onResize event
logResizeCount('after second resize') // 1
expect(ContainerDimensions.prototype.onResize.calledTwice).to.be.true
ContainerDimensions.prototype.onResize.restore()
done()
}, 10)
}) |
Apparently this is a bug in how I use element resize detector: #12 (comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In looking at the test below, if I make a few modifications which should presumable break the test, it still passes. I've removed the logic that I believe is representing the resize, but it still passes the test.
Original Test (passing)
Modified Test (still passing, but how?)
The text was updated successfully, but these errors were encountered: