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

Fix params comparisons for post and put requests - Breaking Change #387

Merged

Conversation

marcbachmann
Copy link
Collaborator

@marcbachmann marcbachmann commented Jul 31, 2024

Breaking Change 💥

  • Change the parameters of the methods to align it to the one of axios.
    The last parameter must be a config object with {params, headers} instead of just the headers.
    If you've always only used two parameters, you won't have to change anything.

    Methods with data param:

    • mock.onPost(url, data, headers) > mock.onPost(url, data, {params, headers})
    • mock.onPut(url, data, headers) > mock.onPost(url, data, {params, headers})
    • mock.onPatch(url, data, headers) > mock.onPatch(url, data, {params, headers})
    • mock.onAny(url, data, headers) > mock.onAny(url, {data, params, headers})

    Methods without data param:

    • mock.onGet(url, {params}, headers) > mock.onGet(url, {params, headers})
    • mock.onDelete(url, {params}, headers) > mock.onDelete(url, {params, headers})
    • mock.onHead(url, {params}, headers) > mock.onHead(url, {params, headers})
    • mock.onOptions(url, {params}, headers) > mock.onOptions(url, {params, headers})

    An error is reported if one accidentally passes the headers directly instead of `{headers: {}}.

    e.g. Error: Invalid config property Header-test provided to onPatch. Config: {"Header-test":"test-header"}

@marcbachmann marcbachmann marked this pull request as ready for review July 31, 2024 14:41
@marcbachmann marcbachmann force-pushed the fix-params-comparisons-for-post-and-put-requests branch 4 times, most recently from 58255c4 to 5ff6d1d Compare July 31, 2024 15:01
@marcbachmann marcbachmann changed the title Fix params comparisons for post and put requests Fix params comparisons for post and put requests - Breaking Change Aug 4, 2024
@marcbachmann marcbachmann force-pushed the fix-params-comparisons-for-post-and-put-requests branch 2 times, most recently from ef90a74 to 0779d34 Compare August 4, 2024 18:13
…utes

BREAKING CHANGE: Change the parameters of the methods to align it to the one of axios.
The last parameter must be a config object with {params, headers} instead of just the headers.
If you've always only used two parameters, you won't have to change anything.

Methods with data param:
- `mock.onPost(url, data, headers)` > `mock.onPost(url, data, {params, headers})`
- `mock.onPut(url, data, headers)` > `mock.onPost(url, data, {params, headers})`
- `mock.onPatch(url, data, headers)` > `mock.onPatch(url, data, {params, headers})`
- `mock.onAny(url, data, headers)` > `mock.onAny(url, {data, params, headers})`

Methods without data param:
- `mock.onGet(url, {params}, headers)` > `mock.onGet(url, {params, headers})`
- `mock.onDelete(url, {params}, headers)` > `mock.onDelete(url, {params, headers})`
- `mock.onHead(url, {params}, headers)` > `mock.onHead(url, {params, headers})`
- `mock.onOptions(url, {params}, headers)` > `mock.onOptions(url, {params, headers})`
@marcbachmann marcbachmann force-pushed the fix-params-comparisons-for-post-and-put-requests branch from 0779d34 to d0f32f9 Compare August 4, 2024 18:16
An error is reported if one accidentally passes the headers directly instead of `{headers: {}}.
e.g. Error: Invalid config attribute Header-test provided to onPatch. Config: {"Header-test":"test-header"}
src/index.js Outdated Show resolved Hide resolved
types/index.d.ts Outdated Show resolved Hide resolved
@marcbachmann marcbachmann merged commit 999ef1c into master Aug 5, 2024
13 checks passed
@marcbachmann marcbachmann deleted the fix-params-comparisons-for-post-and-put-requests branch August 5, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants