Skip to content

Commit

Permalink
モックのHTTPステータスコードについてaxiosから提供されるEnumを使用するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
KentaHizume committed Dec 26, 2024
1 parent 1011279 commit 1e745f5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HttpStatusCode } from 'axios';
import { HttpResponse, http } from 'msw';

export const assetsHandlers = [
Expand All @@ -6,7 +7,7 @@ export const assetsHandlers = [
`/mock/images/${params.assetCode}.png`,
).then((response) => response.arrayBuffer());
return HttpResponse.arrayBuffer(imageBuffer, {
status: 200,
status: HttpStatusCode.Ok,
headers: {
'Content-Type': 'image/png',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { GetCatalogBrandsResponse } from '@/generated/api-client';
import { HttpStatusCode } from 'axios';
import { HttpResponse, http } from 'msw';

const catalogBrands: GetCatalogBrandsResponse[] = [
Expand All @@ -18,6 +19,6 @@ const catalogBrands: GetCatalogBrandsResponse[] = [

export const catalogBrandsHandlers = [
http.get('/api/catalog-brands', () => {
return HttpResponse.json(catalogBrands, { status: 200 });
return HttpResponse.json(catalogBrands, { status: HttpStatusCode.Ok });
}),
];
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { GetCatalogCategoriesResponse } from '@/generated/api-client';
import { HttpStatusCode } from 'axios';
import { HttpResponse, http } from 'msw';

const catalogCategories: GetCatalogCategoriesResponse[] = [
Expand All @@ -18,6 +19,6 @@ const catalogCategories: GetCatalogCategoriesResponse[] = [

export const catalogCategoriesHandlers = [
http.get('/api/catalog-categories', () => {
return HttpResponse.json(catalogCategories, { status: 200 });
return HttpResponse.json(catalogCategories, { status: HttpStatusCode.Ok });
}),
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
PostCatalogItemRequest,
PutCatalogItemRequest,
} from '@/generated/api-client';
import { HttpStatusCode } from './httpStatusCode';
import { HttpStatusCode } from 'axios';
import { pagedListCatalogItem, catalogItems } from '../data/catalogItems';

type GetCatalogItemParams = {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpResponse, http } from 'msw';
import type { GetLoginUserResponse } from '@/generated/api-client';
import { HttpStatusCode } from 'axios';

const user: GetLoginUserResponse = {
userName: '[email protected]',
Expand All @@ -8,6 +9,6 @@ const user: GetLoginUserResponse = {

export const usersHandlers = [
http.get('/api/users', () => {
return HttpResponse.json(user, { status: 200 });
return HttpResponse.json(user, { status: HttpStatusCode.Ok });
}),
];

0 comments on commit 1e745f5

Please sign in to comment.