mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Add support for i18n using lingui
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import api from '../../src/api';
|
||||
import { API_CONFIG } from '../../src/endpoints';
|
||||
import About from '../../src/components/About';
|
||||
@@ -9,14 +10,22 @@ describe('<About />', () => {
|
||||
let closeButton;
|
||||
|
||||
test('initially renders without crashing', () => {
|
||||
aboutWrapper = mount(<About isOpen />);
|
||||
aboutWrapper = mount(
|
||||
<I18nProvider>
|
||||
<About isOpen />
|
||||
</I18nProvider>
|
||||
);
|
||||
expect(aboutWrapper.length).toBe(1);
|
||||
aboutWrapper.unmount();
|
||||
});
|
||||
|
||||
test('close button calls onAboutModalClose', () => {
|
||||
const onAboutModalClose = jest.fn();
|
||||
aboutWrapper = mount(<About isOpen onAboutModalClose={onAboutModalClose} />);
|
||||
aboutWrapper = mount(
|
||||
<I18nProvider>
|
||||
<About isOpen onAboutModalClose={onAboutModalClose} />
|
||||
</I18nProvider>
|
||||
);
|
||||
closeButton = aboutWrapper.find('AboutModalBoxCloseButton Button');
|
||||
closeButton.simulate('click');
|
||||
expect(onAboutModalClose).toBeCalled();
|
||||
@@ -29,9 +38,15 @@ describe('<About />', () => {
|
||||
err.response = { status: 404, message: 'problem' };
|
||||
return Promise.reject(err);
|
||||
});
|
||||
aboutWrapper = mount(<About isOpen />);
|
||||
await aboutWrapper.instance().componentDidMount();
|
||||
expect(aboutWrapper.state('error').response.status).toBe(404);
|
||||
aboutWrapper = mount(
|
||||
<I18nProvider>
|
||||
<About isOpen />
|
||||
</I18nProvider>
|
||||
);
|
||||
|
||||
const aboutComponentInstance = aboutWrapper.find(About).instance();
|
||||
await aboutComponentInstance.componentDidMount();
|
||||
expect(aboutComponentInstance.state.error.response.status).toBe(404);
|
||||
aboutWrapper.unmount();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user