Skip to content

Commit

Permalink
test(homepage): test async render of homepage component
Browse files Browse the repository at this point in the history
  • Loading branch information
BradenM committed Dec 22, 2019
1 parent 5f942a2 commit 4796db2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
20 changes: 0 additions & 20 deletions app/components/pages/HomePage/messages.js

This file was deleted.

17 changes: 16 additions & 1 deletion app/components/pages/HomePage/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,32 @@ import { render } from '@testing-library/react';
// import '@testing-library/jest-dom/extend-expect'; // add some helpful assertions
import { createStates, withRouter } from 'utils/testHelpers';
import HomePage, { HomeBanner, HomeHero } from '../index';
import AsyncHomePage from '../loadable';

const testProps = {
...HomeBanner,
...HomeHero,
};

describe('<HomePage />', () => {
let store;
let history;

beforeAll(() => {
const states = createStates();
store = states.store;
history = states.history;
});

it('Expect to not log errors in console', () => {
const spy = jest.spyOn(global.console, 'error');
const { store, history } = createStates();
render(withRouter(HomePage, store, history, testProps));
expect(spy).not.toHaveBeenCalled();
});

it('Expect to nog log errors in console when loaded asynchronously', () => {
const spy = jest.spyOn(global.console, 'error');
render(withRouter(AsyncHomePage, store, history, testProps));
expect(spy).not.toHaveBeenCalled();
});
});

0 comments on commit 4796db2

Please sign in to comment.