Skip to content

Commit

Permalink
fix(docgen): add extra test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rustam-e committed Jan 24, 2025
1 parent 4ffbd60 commit 621c231
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const DocGenSidebar = ({ getDocGenTags }: Props) => {
// @ts-ignore

const { data } = response || [];

// anything that is not an image tag for this view is treated as a text tag
const textTags = data?.filter(tag => tag.tag_type !== 'image') || [];
const imageTags = data?.filter(tag => tag.tag_type === 'image') || [];
Expand Down
23 changes: 23 additions & 0 deletions src/elements/content-sidebar/__tests__/DocGenSidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const docGenSidebarProps = {
),
};

const processAndResolveMock = jest.fn()
.mockImplementationOnce(() => Promise.resolve({
message: "Processing tags for this file."
}))
.mockImplementationOnce(() => Promise.resolve({
pagination: {},
data: mockData,
}));

const noTagsMock = jest.fn().mockReturnValue(Promise.resolve({ data: [] }));
const processingTagsMock = jest.fn().mockReturnValue(Promise.resolve({
"message": "Processing tags for this file."
Expand Down Expand Up @@ -110,6 +119,20 @@ describe('elements/content-sidebar/DocGenSidebar', () => {
await waitFor(() => expect(processingTagsMock).toHaveBeenCalledTimes(10));
});

test('should re-trigger loadTags retrigger and successfully display the tags', async () => {
renderComponent({
getDocGenTags: processAndResolveMock,
});

await jest.advanceTimersByTime(1000);
await jest.advanceTimersByTime(1000);

await waitFor(() => expect(processAndResolveMock).toHaveBeenCalledTimes(2));
const parentTag = await screen.findByText('about');

expect(parentTag).toBeVisible();
});


test('should re-trigger getDocGenTags on click on refresh button', async () => {
renderComponent({
Expand Down

0 comments on commit 621c231

Please sign in to comment.