Skip to content

Commit

Permalink
fix: query should be on the list of extra args (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx authored May 23, 2024
1 parent e1c85a0 commit 50e40d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ export class Paginator {
});
});
if (!callback) {
return promise.then(results => [results, ...otherArgs]);
return promise.then(results => [results, query, ...otherArgs]);
}
promise.then(
results => callback(null, results, ...otherArgs),
results => callback(null, results, query, ...otherArgs),
(err: Error) => callback(err)
);
}
Expand Down
8 changes: 6 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,12 @@ describe('paginator', () => {
callback(
err: Error,
results_: {},
query: {},
fakeRes: {},
anotherArg: number
) {
assert.deepStrictEqual(results_, results);
assert.deepStrictEqual(query, undefined);
assert.deepStrictEqual(fakeRes, {msg: 'OK'});
assert.deepStrictEqual(anotherArg, 10);
done();
Expand Down Expand Up @@ -467,7 +469,7 @@ describe('paginator', () => {
);
});

it('should resolve with all results and extra args', () => {
it('should resolve with all results and extra args', done => {
const results = [{a: 1}, {b: 2}, {c: 3}];
const args: any[] = [{msg: 'OK'}, 10];

Expand All @@ -483,10 +485,12 @@ describe('paginator', () => {

paginator
.run_(parsedArguments, util.noop)
.then(([results_, fakeRes, anotherArg]: unknown[]) => {
.then(([results_, query_, fakeRes, anotherArg]: unknown[]) => {
assert.deepStrictEqual(results_, results);
assert.deepStrictEqual(query_, undefined);
assert.deepEqual(fakeRes, {msg: 'OK'});
assert.deepEqual(anotherArg, 10);
done();
});
});
});
Expand Down

0 comments on commit 50e40d0

Please sign in to comment.