this is a bit weird. When I debug, tab ends up being a shallow wrapper which is fine and expected. But.. when I look at the nodes array in WebStorm of the shallow wrapper, it's always returning the
video: https://youtu.be/yyhxWI6oLPA
import { expect, shallow, React } from 'test/test.helpers';
import { fakeStore } from 'test/test.doubles';
import HeaderSearch from 'app/components/Header/HeaderSearch/index';
describe('Header Search Category Tab', () => {
describe('Successful', () => {
describe('displayed as fourth category', () => {
it('contains search', () => {
const search = shallow(<HeaderSearch store={fakeStore()} />).dive().find('.ft-search');
expect(search).to.exist;
})
})
})
})
Container
I'm giving the bare minimal, the ... means "there is code here":
export class HeaderSearch extends Component {
constructor() {
...
}
render() {
...
return (
<Search />
);
}
}
function mapStateToProps(state) {
return {
...
};
}
const TimeoutHeaderSearch = ReactTimeout(connect(mapStateToProps, {
...
})(HeaderSearch));
TimeoutHeaderSearch.fetchData = ({ store }) => store.dispatch(fetchSearch());
Here's the debug showing what was returned
For one, .exist won't ever be false, because .find always returns a wrapper.
Instead, assert on the length of the wrapper, and what it contains.
yea I can't believe I did that, thanks for the catch. I noticed the same and changed it actually yesterday.
side not, "one what it contains' I usually use find()
Closing since this seems answered; happy to reopen if that's not the case :-)