mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Fix unit test error in HostAdd
This commit is contained in:
@@ -30,7 +30,7 @@ describe('<HostAdd />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should post to api', async () => {
|
test('handleSubmit should post to api', async () => {
|
||||||
act(() => {
|
await act(async () => {
|
||||||
wrapper.find('HostForm').prop('handleSubmit')(hostData);
|
wrapper.find('HostForm').prop('handleSubmit')(hostData);
|
||||||
});
|
});
|
||||||
expect(HostsAPI.create).toHaveBeenCalledWith(hostData);
|
expect(HostsAPI.create).toHaveBeenCalledWith(hostData);
|
||||||
@@ -44,12 +44,14 @@ describe('<HostAdd />', () => {
|
|||||||
test('successful form submission should trigger redirect', async () => {
|
test('successful form submission should trigger redirect', async () => {
|
||||||
HostsAPI.create.mockResolvedValueOnce({
|
HostsAPI.create.mockResolvedValueOnce({
|
||||||
data: {
|
data: {
|
||||||
id: 5,
|
|
||||||
...hostData,
|
...hostData,
|
||||||
|
id: 5,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await waitForElement(wrapper, 'button[aria-label="Save"]');
|
await waitForElement(wrapper, 'button[aria-label="Save"]');
|
||||||
await wrapper.find('HostForm').invoke('handleSubmit')(hostData);
|
await act(async () => {
|
||||||
|
wrapper.find('HostForm').invoke('handleSubmit')(hostData);
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual('/hosts/5/details');
|
expect(history.location.pathname).toEqual('/hosts/5/details');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user