Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass allItems and currentItems to _pagination.paginate() #1100

Merged
merged 28 commits into from Mar 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions test/pagination.ts
Expand Up @@ -72,7 +72,16 @@ test('filters elements', withServer, async (t, server, got) => {

const result = await got.paginate.all({
_pagination: {
filter: element => element !== 2
filter: (element, allItems, currentItems) => {
if (!Array.isArray(allItems)) {
throw new Error('allItems is not an array');
}
if (!Array.isArray(currentItems)) {
throw new Error('currentItems is not an array');
}
jaulz marked this conversation as resolved.
Show resolved Hide resolved

return element !== 2
}
}
});

Expand Down Expand Up @@ -174,7 +183,16 @@ test('`shouldContinue` works', withServer, async (t, server, got) => {

const options = {
_pagination: {
shouldContinue: () => false
shouldContinue: (element: any, allItems: any, currentItems: any) => {
if (!Array.isArray(allItems)) {
throw new Error('allItems is not an array');
}
if (!Array.isArray(currentItems)) {
throw new Error('currentItems is not an array');
}
jaulz marked this conversation as resolved.
Show resolved Hide resolved

return false
}
}
};

Expand Down