I am working in a React Component where i have simply just refactored one small part of the code, the problem is that i have some unit test failing after this change
This is how it was looking before
let PageHeaderRef;
<header className="jt-list__header" ref={(el: HTMLElement) => { PageheaderRef = el; }}>
{ header }
</header>
// part not changed
<RacecardContainer onRender={() => PageHeaderRef && PageHeaderRef.scrollIntoView()} />
This is after my changes
let PageHeaderRef;
<PageHeader style="primary" ref={(el: HTMLElement) => { PageHeaderRef = el; }}>
{ header }
</PageHeader>
// part not changed
<RacecardContainer onRender={() => PageHeaderRef && PageHeaderRef.scrollIntoView()} />
As you can see i have just reused a PageHeader
component imported from a framework using the style primary. The style ‘primary
’ is applying the class .sb-page-header--primary
This is the Unit Testing which is failing, in the last line it is expected to be ‘false’
and not ’true’
const wrapper = mount(<ListRowOpen />);
const headerEl = wrapper.find(headerCls).getDOMNode();
const onRender = racecardContainerStub.firstCall.args[0].onRender;
const scrollSpy = headerEl.scrollIntoView = sinon.spy();
expect(scrollSpy.called).to.equal(false);
onRender();
expect(scrollSpy.called).to.equal(true); // line with the error //
Obviously the headerCls has been changed from jt-list__header
to the sb-page-header--primary
This test was not failing before my changes
It seems like that the element i am referring to access in the Dom and then passing to the RacecardContainer is not now recognised after i have replaced this header
html with the PageHeader
component
Aucun commentaire:
Enregistrer un commentaire