Skip to content

Commit

Permalink
Update storybook.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tsengyushiang authored Sep 2, 2024
1 parent 38b1d8a commit 8226004
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions frontend/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,31 @@ export default preview
```javascript
import { http, HttpResponse } from 'msw'

const mockPost = http.post(`${HOST}/post/api`, async ({ request }) => {
const payload = await request.json();
return HttpResponse.json({
foo: "foo",
});
});

const mockGet = http.get(`${HOST}/get/api`, async ({ request }) => {
const url = new URL(request.url);
const param = url.searchParams.get("id");
return HttpResponse.json({
foo: param,
});
});

export const Demo = {
args: {
// others props for components
},
parameters: {
msw: {
handlers: [
http.get(`${HOST}/use`, async ({ request }) => {
const payload = await request.json();
return HttpResponse.json({
foo: 'foo',
})
}),
],
handlers: [mockPost, mockGet],
},
},
}
};
```

## Setup storybook-test-runner
Expand Down

0 comments on commit 8226004

Please sign in to comment.