Skip to content

Commit

Permalink
stringifys filters
Browse files Browse the repository at this point in the history
  • Loading branch information
lcflight committed Feb 29, 2024
1 parent f23bf30 commit ebde45e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/interceptors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ describe("Request Interceptor", () => {

await Promise.all(promises);
});

it("stringifys the filters", async () => {
const config = await interceptors.onRequest({
params: { filters: { id: 1 } },
} as any);

expect(config.params).toEqual(
expect.objectContaining({ filters: '{"id":1}' }),
);
});
});
6 changes: 6 additions & 0 deletions src/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export class Interceptors {
...(config.params as Record<string, unknown>),
};

const params = config.params as { filters?: unknown };

if (params.filters !== undefined) {
params.filters = JSON.stringify(params.filters);
}

return new Promise((resolve) => {
const interval = setInterval(() => {
if (this.pending < MAX_REQUESTS_COUNT) {
Expand Down

0 comments on commit ebde45e

Please sign in to comment.