masakudamatsu / line-height-picker

A front-end web app that helps web designers/developers pick the best line-height value for their websites
https://line-height-picker.vercel.app
MIT License
2 stars 1 forks source link

Fix FontFileUploader.test.js for using useHistory() from react-router #195

Closed masakudamatsu closed 4 years ago

masakudamatsu commented 4 years ago

We can mock the history.push() function as follows (source: https://stackoverflow.com/a/59451956/11847654)

const mockHistoryPush = jest.fn();

jest.mock('react-router', () => ({
  ...jest.requireActual('react-router'),
  useHistory: () => ({
    push: mockHistoryPush,
  }),
}));