Skip to content

Commit

Permalink
fix(test): Set limit on first page (#160)
Browse files Browse the repository at this point in the history
## Describe your changes

The first page wasn't including a limit param, and that caused issues
for tests.

## Issue ticket number and link

## Checklist before requesting a review (skip if just adding/editing
APIs & templates)

-   [ ] I added tests, otherwise the reason is:
-   [ ] External API requests have `retries`
-   [ ] Pagination is used where appropriate
- [ ] The built in `nango.paginate` call is used instead of a `while
(true)` loop
- [ ] Third party requests are NOT parallelized (this can cause issues
with rate limits)
- [ ] If a sync requires metadata the `nango.yaml` has `auto_start:
false`
-   [ ] If the sync is a `full` sync then `track_deletes: true` is set
- [ ] I followed the best practices and guidelines from the [Writing
Integration
Scripts](/NangoHQ/integration-templates/blob/main/WRITING_INTEGRATION_SCRIPTS.md)
doc
  • Loading branch information
nalanj authored Dec 18, 2024
1 parent f25e8ca commit dbcc525
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class NangoActionMock {
const paginateInBody = ['post', 'put', 'patch'].includes(args.method.toLowerCase());
const updatedBodyOrParams = paginateInBody ? (args.data as Record<string, any>) || {} : args.params || {};

if (args.paginate['limit']) {
const limitParameterName = args.paginate.limit_name_in_request!;

updatedBodyOrParams[limitParameterName] = args.paginate['limit'];
}

if (args.paginate?.type === 'cursor') {
yield* this.cursorPaginate(args, updatedBodyOrParams, paginateInBody);
} else if (args.paginate?.type === 'link') {
Expand Down

0 comments on commit dbcc525

Please sign in to comment.