Skip to content

Commit

Permalink
Fix _pagination not falling back to defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Feb 8, 2020
1 parent 3c6ca29 commit ff1dba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/normalize-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const preNormalizeArguments = (options: Options, defaults?: NormalizedOpt

// `options._pagination`
if (is.object(options._pagination)) {
if (defaults && !(Reflect.has(options, 'pagination') && is.undefined(options._pagination))) {
if (defaults && !(Reflect.has(options, '_pagination') && is.undefined(options._pagination))) {
options._pagination = {
...defaults.pagination,
...options._pagination
Expand Down
8 changes: 8 additions & 0 deletions test/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ test('retrieves all elements', withServer, async (t, server, got) => {
t.deepEqual(result, [1, 2]);
});

test('points to defaults when extending Got without custom `_pagination`', withServer, async (t, server, got) => {
attachHandler(server, 2);

const result = await got.extend().paginate.all('');

t.deepEqual(result, [1, 2]);
});

test('filters elements', withServer, async (t, server, got) => {
attachHandler(server, 3);

Expand Down

0 comments on commit ff1dba1

Please sign in to comment.