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

feat: request match by headers (#16) #102

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

diego-aquino
Copy link
Member

@diego-aquino diego-aquino commented 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.
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 #16.

@diego-aquino diego-aquino added this to the v0.3.0 milestone Mar 15, 2024
@diego-aquino diego-aquino self-assigned this Mar 15, 2024
@diego-aquino diego-aquino enabled auto-merge (squash) March 15, 2024 15:37
@diego-aquino diego-aquino merged commit e406e1d into canary Mar 15, 2024
4 checks passed
@diego-aquino diego-aquino deleted the @diego-aquino/16-request-match-by-headers branch March 15, 2024 17:24
@diego-aquino diego-aquino linked an issue Mar 15, 2024 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP interceptor request match by headers
1 participant