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 headers #16

Closed
3 tasks done
diego-aquino opened this issue Jan 8, 2024 · 0 comments · Fixed by #102
Closed
3 tasks done

HTTP interceptor request match by headers #16

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

Comments

@diego-aquino
Copy link
Member

diego-aquino commented Jan 8, 2024

  • The HTTP request tracker should support:
    • Defining headers to match requests
    • Receiving a second, optional argument to whether the match should be exact or not (default: false)
      const listTracker = authInterceptor
        .get('/users')
        .with({
          headers: { 'content-type': 'application/json' },
          exact: true,
        })
        .respond({
          status: 200,
          body: [user],
        });
@diego-aquino diego-aquino changed the title HTTP interceptor request match by minimum headers HTTP interceptor request match by headers Jan 8, 2024
@diego-aquino diego-aquino added the enhancement New feature or request label Jan 8, 2024
@diego-aquino diego-aquino added this to the v0.4.0 milestone Jan 8, 2024
@diego-aquino diego-aquino changed the title HTTP interceptor request match by headers HTTP interceptor request match by headers Feb 19, 2024
@diego-aquino diego-aquino modified the milestones: v0.4.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 diego-aquino self-assigned this Mar 12, 2024
diego-aquino added a commit that referenced this issue Mar 15, 2024
### Features
- [#zimic] Added support to restrict request trackers by HTTP headers.
- [#zimic] Added support to compare equality and containment of HTTP
headers.

### Fixes
- [#zimic] Fixed the semantics of search param comparisons. Now
`param1.contains(param2)` returns `true` only if all key-value pairs of
`param2` are present in `param1`, regardless of `param1` having more
key-pairs than `param2`. The previous behavior was that
`param1.contains(param2)` would return `true` only if all key-value
pairs of `param1` were present in `param2`, which is not correct because
the semantics are reversed.

```ts
const creationTracker = authInterceptor
  .post('/users')
  .with({
    headers: { 'content-type': 'application/json' },
  })
  .respond((request) => {
    const user: User = {
      id: crypto.randomUUID(),
      name: request.body.name,
      email: request.body.email,
    };

    return {
      status: 201,
      body: user,
    };
  });

const response = await createUser(creationPayload);
expect(response.status).toBe(201);
```

Closes #86.
@diego-aquino diego-aquino linked a pull request Mar 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant