and index.jsx tests

This commit is contained in:
John Mitchell 2018-11-02 13:45:11 -04:00
parent 19dcf5ed59
commit 90d1ab88b1
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
2 changed files with 33 additions and 5 deletions

22
__tests__/index.test.jsx Normal file
View File

@ -0,0 +1,22 @@
import React from 'react';
import ReactDOM from 'react-dom';
import api from '../src/api';
import indexToRender from '../src/index';
const custom_logo = (<div>logo</div>);
const custom_login_info = 'custom login info';
jest.mock('react-dom', () => ({ render: jest.fn() }));
describe('index.jsx', () => {
test('renders without crashing', async () => {
api.getRoot = jest.fn().mockImplementation(() => Promise
.resolve({ data: { custom_logo, custom_login_info } }));
await indexToRender();
expect(ReactDOM.render).toHaveBeenCalled();
});
});

View File

@ -11,9 +11,15 @@ import './app.scss';
const el = document.getElementById('app');
api.getRoot()
.then(({ data }) => {
const { custom_logo, custom_login_info } = data;
const main = () => {
api.getRoot()
.then(({ data }) => {
const { custom_logo, custom_login_info } = data;
render(<App logo={custom_logo} loginInfo={custom_login_info} />, el);
});
render(<App logo={custom_logo} loginInfo={custom_login_info} />, el);
});
};
main();
export default main;