Skip to content

Instantly share code, notes, and snippets.

View nerfologist's full-sized avatar
🏠
Working from home

Marco Arduini nerfologist

🏠
Working from home
  • Nebulab
  • Parma, Italy
View GitHub Profile
@nerfologist
nerfologist / stubRouterContext.js
Last active February 9, 2017 13:24
Stub router context in tests
import React, { Component, PropTypes } from 'react';
/*
* provide a component with a stubbed router context; optionally
* pass your own stubs such as jest.fn() to check that they are called
* modern version of https://gist.github.com/jaketrent/f68028eedd4f1ddf7997
* HOC technique by Rem Zolotykh from https://youtu.be/q5OmQvh4R3s
* all credit goes to the original poster
* */
const stubRouterContext = (ComposedComponent, stubs) => {