-
Notifications
You must be signed in to change notification settings - Fork 28
Closed

Description
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)
it('calls onResize when parent has been resized', (done) => {
spy(ContainerDimensions.prototype, 'onResize')
const wrapper = mount(
<div ref="node" id="node" style={{ width: 10 }}>
<ContainerDimensions>
<MyComponent />
</ContainerDimensions>
</div>
, { attachTo: document.body })
const el = wrapper.render()
el.css('width', 10)
setTimeout(() => {
el.css('width', 100) // Triggering onResize event
expect(ContainerDimensions.prototype.onResize.calledTwice).to.be.true
ContainerDimensions.prototype.onResize.restore()
done()
}, 10)
})
Modified Test (still passing, but how?)
it('calls onResize when parent has been resized', (done) => {
spy(ContainerDimensions.prototype, 'onResize')
const wrapper = mount(
<div ref="node" id="node" style={{ width: 10 }}>
<ContainerDimensions>
<MyComponent />
</ContainerDimensions>
</div>
, { attachTo: document.body })
// =========================================================
// const el = wrapper.render()
// el.css('width', 10)
// =========================================================
setTimeout(() => {
// =====================================================
// el.css('width', 100) // Triggering onResize event
// =====================================================
expect(ContainerDimensions.prototype.onResize.calledTwice).to.be.true
ContainerDimensions.prototype.onResize.restore()
done()
}, 10)
})
Metadata
Metadata
Assignees
Labels
No labels