Skip to content

Commit

Permalink
Merge #1901
Browse files Browse the repository at this point in the history
1901: refactor(msw): get rid of url-join r=herschel666 a=herschel666

<details>
<summary>Bors merge bot cheat sheet</summary>

We are using [bors-ng](https://github.com/bors-ng/bors-ng) to automate merging of our pull requests. The following table provides a summary of commands that are available to reviewers (members of this repository with push access) and delegates (in case of `bors delegate+` or `bors delegate=[list]`).

| Syntax | Description |
| --- | --- |
| bors merge | Run the test suite and push to master if it passes. Short for "reviewed: looks good." |
| bors merge- | Cancel an r+, r=, merge, or merge= |
| bors try | Run the test suite without pushing to master. |
| bors try- | Cancel a try |
| bors delegate+ | Allow the pull request author to merge their changes. |
| bors delegate=[list] | Allow the listed users to r+ this pull request's changes. |
| bors retry | Run the previous command a second time. |

This is a short collection of opinionated commands. For a full list of the commands read the [bors reference](https://bors.tech/documentation/).

</details>


Co-authored-by: Emanuel Kluge <[email protected]>
  • Loading branch information
bors[bot] and Emanuel Kluge authored Jul 1, 2021
2 parents ca69e6b + fda4320 commit 61eedbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions packages/msw/integration.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// @ts-check

const { fetch } = require('cross-fetch');
const joinUrl = require('url-join');

const getMockEndpoint = () => {
const getMockEndpoint = (pathName) => {
if (typeof process.env.MOCK_HOST !== 'string') {
throw new Error('Please define MOCK_HOST.');
}

return new URL(process.env.MOCK_HOST).toString();
return new URL(pathName, process.env.MOCK_HOST).toString();
};

/** @type {import('hops-msw/integration').mockGraphQLQuery} */
Expand Down Expand Up @@ -73,7 +72,7 @@ const mockDeleteRequest = (pathName, data) => {

/** @type {import('hops-msw/integration').registerServerMocks} */
const registerServerMocks = async (...mocks) => {
await fetch(joinUrl(getMockEndpoint(), '/_mocks/register'), {
await fetch(getMockEndpoint('/_mocks/register'), {
method: 'POST',
headers: {
'content-type': 'application/json',
Expand All @@ -84,7 +83,7 @@ const registerServerMocks = async (...mocks) => {

/** @type {import('hops-msw/integration').resetServerMocks} */
const resetServerMocks = async () => {
await fetch(joinUrl(getMockEndpoint(), '/_mocks/reset'));
await fetch(getMockEndpoint('/_mocks/reset'));
};

module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions packages/msw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"cross-fetch": "^3.1.4",
"execa": "^5.1.1",
"hops-mixin": "15.0.0-nightly.6",
"msw": "^0.30.0",
"url-join": "^4.0.1"
"msw": "^0.30.0"
},
"homepage": "https://github.com/xing/hops/tree/master/packages/msw#readme"
}

0 comments on commit 61eedbc

Please sign in to comment.