Skip to content

Conversation

@HHHindawy
Copy link
Contributor

No description provided.

@HHHindawy HHHindawy requested a review from a team January 24, 2024 20:00
@linear
Copy link

linear bot commented Jan 24, 2024

CSL-3123 [OS UI PLP] React Serve Tests - Pagination

Business Outcome:

  • I want to test Components rendering on the react server

Definition of done:

  • Reference PR SSR React tests for CioPlpContext #33
  • Add test coverage for rendering on the server
  • Use ReactDOMServer the same function that will be used for React SSR which return a string that will be sent to the client

@HHHindawy HHHindawy changed the title [CSL-3123] Pagination component and hook server side tests [CSL-3123] Pagination component and hook SSR tests Jan 24, 2024
}) => {
const [totalPages, setTotalPages] = useState(0);
const [currentPage, setCurrentPage] = useState<number>();
const [currentPage, setCurrentPage] = useState<number | undefined>(initialPage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're passing initialPage here I think we need to remove this useEffect right?

useEffect(() => {
if (initialPage) {
setCurrentPage(initialPage);
}
}, [initialPage]);

const { result } = renderHookServerSide(() => usePagination(paginationProps), {});
expect(result.totalPages).toBe(0);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's test that pages returned from usePagination is an empty array

windowSize: 10,
};

describe('usePagination', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just so we're consistent with the other tests for the server tests we describe it like "Testing Hook on the server: usePagination"

Copy link
Contributor

@mocca102 mocca102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left small comments. But looking good overall

@HHHindawy HHHindawy requested a review from mocca102 February 5, 2024 19:42
Copy link
Contributor

@mocca102 mocca102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes! LGTM!

@HHHindawy HHHindawy merged commit fd4b4a0 into main Feb 5, 2024
@HHHindawy HHHindawy deleted the csl-3123-os-ui-plp-react-serve-tests-pagination branch February 5, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants