mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Merge pull request #11200 from nixocio/ui_update_unit_tests
Update unit-tests
This commit is contained in:
@@ -69,7 +69,7 @@ describe('<NotificationTemplateListItem />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should call api to copy inventory', async () => {
|
test('should call api to copy inventory', async () => {
|
||||||
NotificationTemplatesAPI.copy.mockResolvedValue();
|
NotificationTemplatesAPI.copy.mockResolvedValue({ name: 'Foo' });
|
||||||
|
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
<table>
|
<table>
|
||||||
@@ -91,7 +91,18 @@ describe('<NotificationTemplateListItem />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should render proper alert modal on copy error', async () => {
|
test('should render proper alert modal on copy error', async () => {
|
||||||
NotificationTemplatesAPI.copy.mockRejectedValue(new Error());
|
NotificationTemplatesAPI.copy.mockRejectedValue(
|
||||||
|
new Error({
|
||||||
|
response: {
|
||||||
|
config: {
|
||||||
|
method: 'post',
|
||||||
|
url: '/api/v2/notification_templates/3/copy',
|
||||||
|
},
|
||||||
|
data: 'An error ocurred',
|
||||||
|
status: 403,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
<table>
|
<table>
|
||||||
@@ -104,10 +115,12 @@ describe('<NotificationTemplateListItem />', () => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
);
|
);
|
||||||
|
expect(wrapper.find('Modal').length).toBe(0);
|
||||||
await act(async () =>
|
await act(async () =>
|
||||||
wrapper.find('Button[aria-label="Copy"]').prop('onClick')()
|
wrapper.find('Button[aria-label="Copy"]').prop('onClick')()
|
||||||
);
|
);
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
|
expect(wrapper.find('Modal').length).toBe(1);
|
||||||
expect(wrapper.find('Modal').prop('isOpen')).toBe(true);
|
expect(wrapper.find('Modal').prop('isOpen')).toBe(true);
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user