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

HTTP interceptor request match by search params #13

Closed
2 of 3 tasks
diego-aquino opened this issue Jan 8, 2024 · 0 comments · Fixed by #99
Closed
2 of 3 tasks

HTTP interceptor request match by search params #13

diego-aquino opened this issue Jan 8, 2024 · 0 comments · Fixed by #99
Assignees
Labels
feature New feature or request
Milestone

Comments

@diego-aquino
Copy link
Member

diego-aquino commented Jan 8, 2024

  • The HTTP request tracker should support:
    • Defining search params to match requests
    • Receiving an optional argument to whether the match should be exact or not (default: false)
      const listTracker = authInterceptor
        .get('/users')
        .with({
          searchParams: { name: nameToFilter },
          exact: true
        })
        .respond({
          status: 200,
          body: [user],
        });
@diego-aquino diego-aquino changed the title HTTP interceptor request match by minimum search params HTTP interceptor request match by search params Jan 8, 2024
@diego-aquino diego-aquino added the feature New feature or request label Jan 8, 2024
@diego-aquino diego-aquino added this to the v0.3.0 milestone Jan 8, 2024
@diego-aquino diego-aquino modified the milestones: v0.3.0, v0.2.0 Feb 20, 2024
@diego-aquino diego-aquino self-assigned this Feb 21, 2024
@diego-aquino diego-aquino modified the milestones: v0.2.0, v0.3.0 Feb 24, 2024
@diego-aquino diego-aquino removed their assignment Feb 24, 2024
diego-aquino added a commit that referenced this issue Mar 11, 2024
### Features
- [#zimic] Added support to restricting request trackers by exact or
partial search params.
- [#zimic] Included `HttpHeadersInit` and `HttpSearchParamsInit` to the
type exports.

```ts
const user = users[0];

const listTracker = authInterceptor
  .get('/users')
  .with({
    searchParams: { name: user.name },
  })
  .respond({
    status: 200,
    body: [user],
  });

const response = await listUsers({ name: user.name });
expect(response.status).toBe(200);

const returnedUsers = (await response.json()) as User[];
expect(returnedUsers).toEqual([user]);
```

Closes #13.
@diego-aquino diego-aquino self-assigned this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant