mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 06:01:25 -03:30
and index.jsx tests
This commit is contained in:
parent
19dcf5ed59
commit
90d1ab88b1
22
__tests__/index.test.jsx
Normal file
22
__tests__/index.test.jsx
Normal 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();
|
||||
});
|
||||
});
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user