Comments (5)
Good question!
from react-container-dimensions.
Can it be the spy cache? I'm not on my computer now so can't check.
from react-container-dimensions.
Seems that the culprit is the attachTo
configuration passed into mount()
. When I remove that, the test breaks.
from react-container-dimensions.
Seems that the calls to el.css()
aren't actually triggering a resize either. onResize()
spy only shows one call made throughout the test.
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)
})
from react-container-dimensions.
Apparently this is a bug in how I use element resize detector: #12 (comment)
from react-container-dimensions.
Related Issues (20)
- element-resize-detector not removed correctly on componentWillUnmount HOT 12
- _reactDom2.default.findDOMNode is not a function HOT 4
- React router props not passed to wrapped component HOT 2
- An in-range update of babel-cli is breaking the build 🚨 HOT 1
- An in-range update of enzyme is breaking the build 🚨 HOT 2
- What is the best way of getting updated top and left values? HOT 3
- An in-range update of mocha is breaking the build 🚨
- An in-range update of lint-staged is breaking the build 🚨 HOT 4
- Container height always zero HOT 1
- Version 10 of node.js has been released
- Calling onResize callback after the component is unmounted
- When print it's not pass the correct width HOT 1
- [Typescript] index.d.ts is not published HOT 1
- Adding a Debounce HOT 7
- Deprecation warnings for [email protected]+ under StrictMode HOT 2
- container updates slow down d3-force convergence HOT 2
- Width and height are initially zero on Apple iPad Safari HOT 1
- Resize not reported for particular case where listener element is in flex layout HOT 1
- Emits warning about prop 'initiated'
- Size calculated is slightly different with size rendered in the browser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-container-dimensions.