-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated tests, react-query, patternfly standards
- Loading branch information
1 parent
2d82261
commit c875447
Showing
10 changed files
with
300 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/Pages/ContentListTable/components/DeleteContentModal/DeleteContent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { render } from '@testing-library/react'; | ||
import { ReactQueryTestWrapper, defaultContentItem } from '../../../../testingHelpers'; | ||
import { useFetchContent } from '../../../../services/Content/ContentQueries'; | ||
import DeleteContentModal from './DeleteContentModal'; | ||
import { ContentOrigin } from '../../../../services/Content/ContentApi'; | ||
|
||
jest.mock('react-query', () => ({ | ||
...jest.requireActual('react-query'), | ||
useQueryClient: jest.fn(), | ||
})); | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
useNavigate: jest.fn(), | ||
useLocation: () => ({ | ||
search: `delete-repository?${defaultContentItem.uuid}`, | ||
}), | ||
})); | ||
|
||
jest.mock('../../ContentListTable', () => ({ | ||
useContentListOutletContext: () => ({ | ||
clearCheckedRepositories: () => undefined, | ||
deletionContext: { | ||
page: 1, | ||
perPage: 21, | ||
filterData: undefined, | ||
contentOrigin: ContentOrigin.EXTERNAL, | ||
sortString: '', | ||
}, | ||
}), | ||
})); | ||
|
||
jest.mock('../../../../Hooks/useRootPath', () => () => 'someUrl'); | ||
|
||
jest.mock('../../../../services/Content/ContentQueries', () => ({ | ||
useDeleteContentItemMutate: () => ({ mutate: () => undefined, isLoading: false }), | ||
useFetchContent: jest.fn(), | ||
})); | ||
|
||
jest.mock('../../../../middleware/AppContext', () => ({ useAppContext: () => ({}) })); | ||
|
||
it('Render Delete Modal', () => { | ||
const data = defaultContentItem; | ||
(useFetchContent as jest.Mock).mockImplementation(() => ({ | ||
isLoading: false, | ||
data: data, | ||
})); | ||
|
||
const { queryByText } = render( | ||
<ReactQueryTestWrapper> | ||
<DeleteContentModal /> | ||
</ReactQueryTestWrapper>, | ||
); | ||
|
||
expect(queryByText(defaultContentItem.name)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.url)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.distribution_arch)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.distribution_versions[0])).toBeInTheDocument(); | ||
expect(queryByText('None')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('Render Delete Modal with no gpg key', () => { | ||
const data = defaultContentItem; | ||
data.gpg_key = ''; | ||
(useFetchContent as jest.Mock).mockImplementation(() => ({ | ||
isLoading: false, | ||
data: data, | ||
})); | ||
|
||
const { queryByText } = render( | ||
<ReactQueryTestWrapper> | ||
<DeleteContentModal /> | ||
</ReactQueryTestWrapper>, | ||
); | ||
|
||
expect(queryByText(defaultContentItem.name)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.url)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.distribution_arch)).toBeInTheDocument(); | ||
expect(queryByText(defaultContentItem.distribution_versions[0])).toBeInTheDocument(); | ||
expect(queryByText('None')).toBeInTheDocument(); | ||
}); |
166 changes: 0 additions & 166 deletions
166
src/Pages/ContentListTable/components/DeleteContentModal/DeleteContent.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.