Skip to content

Commit

Permalink
gocd: port to msw2
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <[email protected]>
  • Loading branch information
freben authored and benjdlambert committed May 8, 2024
1 parent 74f3861 commit 2a153f3
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 150 deletions.
11 changes: 9 additions & 2 deletions workspaces/gocd/plugins/gocd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@types/react": "^16.13.1 || ^17.0.0",
"@types/react-dom": "^18.2.19",
"canvas": "^2.11.2",
"msw": "^1.0.0",
"msw": "^2.0.0",
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
Expand All @@ -71,5 +71,12 @@
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
},
"configSchema": "config.d.ts"
"configSchema": "config.d.ts",
"jest": {
"testEnvironmentOptions": {
"customExportConditions": [
""
]
}
}
}
12 changes: 7 additions & 5 deletions workspaces/gocd/plugins/gocd/src/api/gocdApi.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { setupRequestMockHandlers } from '@backstage/test-utils';
import { GoCdClientApi } from './gocdApi.client';
import { rest } from 'msw';
import { HttpResponse, http } from 'msw';
import { setupServer } from 'msw/node';
import { PipelineHistory } from './gocdApi.model';

Expand All @@ -31,11 +31,13 @@ describe('GoCdClientApi', () => {
};

server.use(
rest.get(
http.get(
'http://example.com/api/proxy/gocd/pipelines/my-pipeline/history',
(req, res, ctx) => {
expect(new URL(req.url).searchParams.get('page_size')).toBe('100');
return res(ctx.json(response));
({ request }) => {
expect(new URL(request.url).searchParams.get('page_size')).toBe(
'100',
);
return HttpResponse.json(response);
},
),
);
Expand Down
Loading

0 comments on commit 2a153f3

Please sign in to comment.