score:6

Accepted answer

You can pass stubbed add in lazyload prop, and check with toHaveBeenCalledWith matcher if it accepts instance()'s lazyref :

describe('lazyload', () => {

  it('should add ref', () => {
    const lazyloadStub = {
        add: jest.fn();
    };

    const wrapper = shallow(
      <Lazyload lazyload={lazyloadStub}>
        <p>doge</p>
      </Lazyload>
    );

    expect(lazyloadStub.add).toHaveBeenCalledWith(wrapper.instance().lazyRef); 
  });
})

Related Query

More Query from same tag