mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 08:08:05 +00:00
RelationInputDataManager: Add tests for load more
This commit is contained in:
parent
49defb77eb
commit
7b52d8ef8e
@ -35,9 +35,16 @@ jest.mock('../../../hooks/useRelation', () => ({
|
|||||||
title: 'Relation 2',
|
title: 'Relation 2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
pageCount: 2,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
fetchNextPage: jest.fn(),
|
||||||
|
hasNextPage: true,
|
||||||
isFetchingNextPage: false,
|
isFetchingNextPage: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSuccess: true,
|
isSuccess: true,
|
||||||
@ -269,16 +276,35 @@ describe('RelationInputDataManager', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Search relations', async () => {});
|
test('Do not render Load More when an entity is created', async () => {
|
||||||
|
const { queryByText } = setup();
|
||||||
|
|
||||||
test('Load more', async () => {
|
expect(await queryByText('Load More')).not.toBeInTheDocument();
|
||||||
const { container } = setup();
|
|
||||||
|
|
||||||
fireEvent.change(container.querySelector('input[name=relation]'), {
|
|
||||||
target: { value: 'search' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
screen.logTestingPlaygroundURL();
|
test('Load more entities', async () => {
|
||||||
|
const { relations } = useRelation();
|
||||||
|
|
||||||
|
useCMEditViewDataManager.mockReturnValueOnce({
|
||||||
|
isCreatingEntry: false,
|
||||||
|
createActionAllowedFields: ['relation'],
|
||||||
|
readActionAllowedFields: ['relation'],
|
||||||
|
updateActionAllowedFields: ['relation'],
|
||||||
|
slug: 'test',
|
||||||
|
initialData: {},
|
||||||
|
loadRelation: jest.fn(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryByText } = setup();
|
||||||
|
const loadMoreNode = await queryByText('Load More');
|
||||||
|
|
||||||
|
expect(loadMoreNode).toBeInTheDocument();
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
fireEvent.click(loadMoreNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(relations.fetchNextPage).toBeCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Open search', async () => {
|
test('Open search', async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user