mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 22:05:07 -02:30
ProjectSyncButton: Add tests.
Add 'disable button and set onClick to undefined on sync' and 'should render tooltip on sync'
This commit is contained in:
@@ -41,6 +41,32 @@ describe('ProjectSyncButton', () => {
|
|||||||
|
|
||||||
expect(ProjectsAPI.sync).toHaveBeenCalledWith(1);
|
expect(ProjectsAPI.sync).toHaveBeenCalledWith(1);
|
||||||
});
|
});
|
||||||
|
test('disable button and set onClick to undefined on sync', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<ProjectSyncButton projectId={1} lastJobStatus="running">
|
||||||
|
{children}
|
||||||
|
</ProjectSyncButton>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('Button').prop('isDisabled')).toBe(true);
|
||||||
|
expect(wrapper.find('Button').prop('onClick')).toBe(undefined);
|
||||||
|
});
|
||||||
|
test('should render tooltip on sync', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<ProjectSyncButton projectId={1} lastJobStatus="running">
|
||||||
|
{children}
|
||||||
|
</ProjectSyncButton>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('Tooltip')).toHaveLength(1);
|
||||||
|
expect(wrapper.find('Tooltip').prop('content')).toEqual(
|
||||||
|
'This project is currently on sync and cannot be clicked until sync process completed'
|
||||||
|
);
|
||||||
|
});
|
||||||
test('displays error modal after unsuccessful sync', async () => {
|
test('displays error modal after unsuccessful sync', async () => {
|
||||||
ProjectsAPI.sync.mockRejectedValue(
|
ProjectsAPI.sync.mockRejectedValue(
|
||||||
new Error({
|
new Error({
|
||||||
|
|||||||
Reference in New Issue
Block a user