mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
and index.jsx tests
This commit is contained in:
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');
|
const el = document.getElementById('app');
|
||||||
|
|
||||||
api.getRoot()
|
const main = () => {
|
||||||
.then(({ data }) => {
|
api.getRoot()
|
||||||
const { custom_logo, custom_login_info } = data;
|
.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;
|
||||||
|
|||||||
Reference in New Issue
Block a user