diff --git a/weatherfit_refactoring/__test__/FeedHashTagSearch.int.test.tsx b/weatherfit_refactoring/__test__/FeedHashTagSearch.int.test.tsx
index d6d9b92..7a84b77 100644
--- a/weatherfit_refactoring/__test__/FeedHashTagSearch.int.test.tsx
+++ b/weatherfit_refactoring/__test__/FeedHashTagSearch.int.test.tsx
@@ -1,7 +1,7 @@
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import FeedSearch from '@/Components/Molecules/post/FeedSearch'
-import FeedContent from '@/Components/Molecules/post/FeedContent'
+import { FeedData } from '@/Store/FeedData'
// msw 서버 설정을 위한 import
import { http, HttpResponse } from 'msw'
@@ -16,7 +16,7 @@ const handlers = [
http.get('https://www.jerneithe.site/board/search', info => {
const url = new URL(info.request.url)
const inputHashtag = url.searchParams.get('hashtags')
- if (inputHashtag === '#카페 #겨울 #행복') {
+ if (inputHashtag === '카페,겨울,행복') {
return HttpResponse.json([feed_data[0]])
}
}),
@@ -42,7 +42,7 @@ describe('피드 페이지 통합 테스트', () => {
// imageUrl:
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJ0OerVCpI1NxInMd93w4JtvWoGmeRf4l8ZlLM7-A--g&s',
// },
- // category: ['숏 패딩', '컨버스'],
+ // category: ['데님 팬츠', '컨버스'],
// hashTag: ['카페', '행복', '겨울'],
// weatherIcon: 'https://openweathermap.org/img/wn/13d.png',
// likelist: [
@@ -62,13 +62,10 @@ describe('피드 페이지 통합 테스트', () => {
test('해시태그 입력 후 검색 버튼 클릭 시 해당하는 코디가 보여진다.', async () => {
// Given
- // 가져온 코디에 대한 blurURI
- const BLURURI: string =
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAKCAIAAAAGpYjXAAAACXBIWXMAAAsTAAALEwEAmpwYAAABBUlEQVR4nAH6AAX/AODb0PHr3/v269DKwmlfWHR1coiIiLu7uQDy7eL68+nW08goJygYFxgLCwxoaGimpqUA8O3i//rtoZ6XExITKCcoBgYHTExMkJCPAO3o3/z262NgXRYWFignJwICAi8tLYaGhgD17+bu6d2Uk4wvLS0VFBUMDAw9PDx5eXkA8e/m8evg8evfMC8wBgYIGBgXb29viIiIAOvl2/fy6O/q4DMyMgAAABYWFnJycouLiwD79uv99uv//vOIh4ZMTEtWVVVycnKJiYgAzcKv2M259+zVr62mpqaidHRya21tg4SFAHJpXHJmWoN1ZV9WTX10bFZRS01HQHhwZvYaezP3SOmNAAAAAElFTkSuQmCC'
render(
-
+ {/* */}
,
)
const input: HTMLInputElement = screen.getByPlaceholderText(
@@ -82,15 +79,7 @@ describe('피드 페이지 통합 테스트', () => {
// Then
await waitFor(() => {
- const nickName = screen.getByText(/홍길동/)
- const temperature = screen.getByText('1.2℃')
- const category = screen.getByLabelText('코디 정보 숏 패딩,컨버스')
- const likeCount = screen.getByText('2')
-
- expect(nickName).toBeInTheDocument()
- expect(temperature).toBeInTheDocument()
- expect(category).toBeInTheDocument()
- expect(likeCount).toBeInTheDocument()
+ expect(FeedData.getState().feedData[0]).toStrictEqual(feed_data[0])
})
})
})
diff --git a/weatherfit_refactoring/package-lock.json b/weatherfit_refactoring/package-lock.json
index e08112b..991952d 100644
--- a/weatherfit_refactoring/package-lock.json
+++ b/weatherfit_refactoring/package-lock.json
@@ -2931,9 +2931,9 @@
}
},
"node_modules/browserslist": {
- "version": "4.22.2",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz",
- "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==",
+ "version": "4.23.1",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.1.tgz",
+ "integrity": "sha512-TUfofFo/KsK/bWZ9TWQ5O26tsWW4Uhmt8IYklbnUa70udB6P2wA7w7o4PY4muaEPBQaAX+CEnmmIA41NVHtPVw==",
"dev": true,
"funding": [
{
@@ -2950,10 +2950,10 @@
}
],
"dependencies": {
- "caniuse-lite": "^1.0.30001565",
- "electron-to-chromium": "^1.4.601",
+ "caniuse-lite": "^1.0.30001629",
+ "electron-to-chromium": "^1.4.796",
"node-releases": "^2.0.14",
- "update-browserslist-db": "^1.0.13"
+ "update-browserslist-db": "^1.0.16"
},
"bin": {
"browserslist": "cli.js"
@@ -3070,9 +3070,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001574",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz",
- "integrity": "sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg==",
+ "version": "1.0.30001636",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz",
+ "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==",
"funding": [
{
"type": "opencollective",
@@ -3695,9 +3695,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.4.620",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.620.tgz",
- "integrity": "sha512-a2fcSHOHrqBJsPNXtf6ZCEZpXrFCcbK1FBxfX3txoqWzNgtEDG1f3M59M98iwxhRW4iMKESnSjbJ310/rkrp0g==",
+ "version": "1.4.803",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.803.tgz",
+ "integrity": "sha512-61H9mLzGOCLLVsnLiRzCbc63uldP0AniRYPV3hbGVtONA1pI7qSGILdbofR7A8TMbOypDocEAjH/e+9k1QIe3g==",
"dev": true
},
"node_modules/emittery": {
@@ -3882,9 +3882,9 @@
}
},
"node_modules/escalade": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
- "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
+ "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
"dev": true,
"engines": {
"node": ">=6"
@@ -7604,9 +7604,9 @@
}
},
"node_modules/picocolors": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
- "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
+ "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew=="
},
"node_modules/picomatch": {
"version": "2.3.1",
@@ -9627,9 +9627,9 @@
}
},
"node_modules/update-browserslist-db": {
- "version": "1.0.13",
- "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
- "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==",
+ "version": "1.0.16",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz",
+ "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==",
"dev": true,
"funding": [
{
@@ -9646,8 +9646,8 @@
}
],
"dependencies": {
- "escalade": "^3.1.1",
- "picocolors": "^1.0.0"
+ "escalade": "^3.1.2",
+ "picocolors": "^1.0.1"
},
"bin": {
"update-browserslist-db": "cli.js"
diff --git a/weatherfit_refactoring/public/dummy_data/feedData.json b/weatherfit_refactoring/public/dummy_data/feedData.json
index a68c757..5341e8e 100644
--- a/weatherfit_refactoring/public/dummy_data/feedData.json
+++ b/weatherfit_refactoring/public/dummy_data/feedData.json
@@ -9,7 +9,7 @@
"imageId": 1,
"imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJ0OerVCpI1NxInMd93w4JtvWoGmeRf4l8ZlLM7-A--g&s"
},
- "category": ["숏 패딩", "컨버스"],
+ "category": ["데님 팬츠", "컨버스"],
"hashTag": ["카페", "행복", "겨울"],
"weatherIcon": "https://openweathermap.org/img/wn/13d.png",
"likelist": [
@@ -27,7 +27,7 @@
},
{
"boardId": 2,
- "category": ["후드 집업", "가죽자켓", "컨버스", "운동화", "베레모"],
+ "category": ["후드 집업", "가죽자켓", "컨버스", "운동화", "셔츠"],
"createDate": "2024-02-14T08:00:00.000Z",
"hashTag": ["카페", "행복", "겨울", "과", "가을", "사이"],
"images": {
diff --git a/weatherfit_refactoring/src/Components/Molecules/FeedCategory.test.tsx b/weatherfit_refactoring/src/Components/Molecules/FeedCategory.test.tsx
new file mode 100644
index 0000000..36765d9
--- /dev/null
+++ b/weatherfit_refactoring/src/Components/Molecules/FeedCategory.test.tsx
@@ -0,0 +1,25 @@
+import { render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import FeedCategory from './FeedCategory'
+
+//카테고리 선택창 Mocking
+
+jest.mock('./post/FeedCategorySelect', () => {
+ return () => 카테고리 선택창
+})
+
+describe('FeedCategory 컴포넌트 유닛 테스트', () => {
+ test('카테고리 버튼을 클릭했을 때, 카테고리 선택창이 나타나는지 확인한다.', async () => {
+ // Given
+ render()
+
+ // When
+ const categoryButton = screen.getAllByRole('button')[0]
+ userEvent.click(categoryButton)
+
+ // Then
+ await waitFor(() => {
+ expect(screen.getByText('카테고리 선택창')).toBeInTheDocument()
+ })
+ })
+})
diff --git a/weatherfit_refactoring/src/Components/Molecules/post/DetailImage.tsx b/weatherfit_refactoring/src/Components/Molecules/post/DetailImage.tsx
index ae08101..d1feec8 100644
--- a/weatherfit_refactoring/src/Components/Molecules/post/DetailImage.tsx
+++ b/weatherfit_refactoring/src/Components/Molecules/post/DetailImage.tsx
@@ -30,7 +30,7 @@ export default function DetailImage({
{images.length > 1 && (
{
test('이미지가 한 개일때, 이미지 이동 버튼이 생성되지 않는다.', () => {
- // Given + When
+ // Given
render()
+
+ //When
const imageButtonElement = screen.queryByTestId('image-button')
// Then
@@ -46,8 +48,10 @@ describe('DetailImage 화면 테스트', () => {
})
test('이미지가 두 개 이상일때, 이미지 이동 버튼이 생성된다.', () => {
- // Given + When
+ // Given
render()
+
+ //When
const imageButtonElement = screen.queryByTestId('image-button')
// Then
@@ -58,9 +62,9 @@ describe('DetailImage 화면 테스트', () => {
it('이전 버튼 클릭 시, 3번째 이미지를 보여준다.', async () => {
// Given
render()
- const prevButton = screen.getByRole('img', { name: 'prev' })
// When
+ const prevButton = screen.getByRole('img', { name: 'prev' })
userEvent.click(prevButton)
// Then
@@ -73,9 +77,9 @@ describe('DetailImage 화면 테스트', () => {
it('이전 버튼을 2번 클릭 시, 2번째 이미지를 보여준다.', async () => {
// Given
render()
- const prevButton = screen.getByRole('img', { name: 'prev' })
// When
+ const prevButton = screen.getByRole('img', { name: 'prev' })
userEvent.click(prevButton)
userEvent.click(prevButton)
@@ -89,9 +93,9 @@ describe('DetailImage 화면 테스트', () => {
it('이전 버튼을 3번 클릭 시, 처음 이미지로 돌아온다', async () => {
// Given
render()
- const prevButton = screen.getByAltText('prev')
// When
+ const prevButton = screen.getByAltText('prev')
userEvent.click(prevButton)
userEvent.click(prevButton)
userEvent.click(prevButton)
@@ -106,9 +110,9 @@ describe('DetailImage 화면 테스트', () => {
it('다음 버튼 클릭 시, 2번째 이미지를 보여준다.', async () => {
// Given
render()
- const nextButton = screen.getByRole('img', { name: 'next' })
// When
+ const nextButton = screen.getByRole('img', { name: 'next' })
userEvent.click(nextButton)
// Then
@@ -121,9 +125,9 @@ describe('DetailImage 화면 테스트', () => {
it('다음 버튼 2번 클릭 시, 3번째 이미지를 보여준다.', async () => {
// Given
render()
- const nextButton = screen.getByRole('img', { name: 'next' })
// When
+ const nextButton = screen.getByRole('img', { name: 'next' })
userEvent.click(nextButton)
userEvent.click(nextButton)
@@ -137,9 +141,9 @@ describe('DetailImage 화면 테스트', () => {
it('다음 버튼 3번 클릭 시, 처음 이미지로 돌아온다.', async () => {
// Given
render()
- const nextButton = screen.getByRole('img', { name: 'next' })
// When
+ const nextButton = screen.getByRole('img', { name: 'next' })
userEvent.click(nextButton)
userEvent.click(nextButton)
userEvent.click(nextButton)
diff --git a/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.int.test.tsx b/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.int.test.tsx
new file mode 100644
index 0000000..a7f7ee0
--- /dev/null
+++ b/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.int.test.tsx
@@ -0,0 +1,250 @@
+// 카테고리 검색 컴포넌트 주요 기능 테스트 목록
+// 초기화 버튼 클릭 시 초기화 되는지 확인 0
+// 카테고리 제목 버튼 클릭 시 하위 카테고리 표시되는지 확인 0
+// 검색 버튼 클릭 시 원하는 코디가 불러와지는지 확인 0
+// 온도 설정에 맞춰서 올바른 코디를 가져오는 지 확인 0
+
+import { render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import FeedCategorySelect from './FeedCategorySelect'
+import { FeedData } from '@/Store/FeedData'
+import { CategorySelectData } from '@/Store/CategorySelectData'
+
+// msw 서버 설정을 위한 import
+import { http, HttpResponse } from 'msw'
+import { setupServer } from 'msw/node'
+import feed_data from '../../../../public/dummy_data/feedData.json'
+
+const handlers = [
+ http.get('https://www.jerneithe.site/board/list', () => {
+ return HttpResponse.json([feed_data[0], feed_data[1]])
+ }),
+
+ http.get('https://www.jerneithe.site/board/search', info => {
+ const url = new URL(info.request.url)
+ const inputCategory = url.searchParams.get('categories')
+ if (inputCategory === '데님 팬츠') {
+ return HttpResponse.json([feed_data[0]])
+ }
+ if (inputCategory === '셔츠') {
+ return HttpResponse.json([feed_data[1]])
+ }
+ if (inputCategory === '') {
+ return HttpResponse.json([feed_data[0], feed_data[1]])
+ }
+ }),
+]
+
+const server = setupServer(...handlers)
+
+beforeAll(() => server.listen())
+afterEach(() => {
+ server.resetHandlers()
+})
+afterAll(() => server.close())
+
+const mockCategoryData = [
+ {
+ id: 1,
+ title: '상의',
+ value: 'top',
+ selectLists: [
+ { list_id: 1, selectList: '티셔츠' },
+ { list_id: 2, selectList: '셔츠' },
+ ],
+ },
+ {
+ id: 2,
+ title: '하의',
+ value: 'bottom',
+ selectLists: [
+ { list_id: 1, selectList: '데님 팬츠' },
+ { list_id: 2, selectList: '코튼 팬츠' },
+ ],
+ },
+]
+
+jest.mock('@/Store/CategoryData', () => ({
+ CategoryData: () => ({ categoryData: mockCategoryData }),
+}))
+
+describe('카테고리 검색 기능에 대한 유닛 테스트', () => {
+ beforeEach(() => {
+ FeedData.setState({ feedData: [] })
+ CategorySelectData.setState({ selectData: [] })
+ })
+
+ test('초기화 버튼 클릭 시 선택한 카테고리가 모두 취소된다.', async () => {
+ // Given
+ render()
+ // When
+ const Button = screen.getByText('상의')
+ userEvent.click(Button)
+ await waitFor(() => {
+ userEvent.click(screen.getAllByText('셔츠')[0])
+ const resetButton = screen.getByText('초기화')
+ userEvent.click(resetButton)
+ // Then
+ expect(CategorySelectData.getState().selectData).toStrictEqual([])
+ })
+ })
+
+ describe('카테고리 제목 버튼 클릭', () => {
+ describe('하위 카테고리가 표시된다.', () => {
+ test('상의 버튼 클릭 시 상의의 하위 카테고리가 표시된다.', async () => {
+ // Given
+ render()
+ // When
+ const Button = screen.getByText('상의')
+ userEvent.click(Button)
+ // Then
+ await waitFor(() => {
+ expect(screen.getByText('티셔츠')).toBeInTheDocument()
+ expect(screen.getByText('셔츠')).toBeInTheDocument()
+ })
+ })
+
+ test('하의 버튼 클릭 시 하의의 하위 카테고리가 표시된다.', async () => {
+ // Given
+ render()
+ // When
+ const Button = screen.getByText('하의')
+ userEvent.click(Button)
+ //Then
+ await waitFor(() => {
+ expect(screen.getByText('데님 팬츠')).toBeInTheDocument()
+ expect(screen.getByText('코튼 팬츠')).toBeInTheDocument()
+ })
+ })
+ })
+ })
+
+ describe('선택한 카테고리에 맞게 코디를 불러온다.', () => {
+ //// 데님 팬츠 선택 후 검색 시 받는 코디 데이터 ////
+ // {
+ // boardId: 1,
+ // nickName: '홍길동',
+ // likeCount: 2,
+ // temperature: 1.2,
+ // images: {
+ // boardId: 1,
+ // imageId: 1,
+ // imageUrl:
+ // 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJ0OerVCpI1NxInMd93w4JtvWoGmeRf4l8ZlLM7-A--g&s',
+ // },
+ // category: ['데님 팬츠', '컨버스'],
+ // hashTag: ['카페', '행복', '겨울'],
+ // weatherIcon: 'https://openweathermap.org/img/wn/13d.png',
+ // likelist: [
+ // {
+ // likeId: 1,
+ // nickName: '김첨지',
+ // },
+ // {
+ // likeId: 2,
+ // nickName: 'lifeis_Happy',
+ // },
+ // ],
+ // modifiedDate: '2024-02-15T08:00:00.000Z',
+ // createDate: '2024-02-13T08:00:00.000Z',
+ // },
+ //// 데님 팬츠 선택 후 검색 시 받는 코디 데이터 ////
+
+ test('데님 팬츠 선택 후 검색 시 맞는 코디를 불러온다', async () => {
+ // Given
+ render()
+ // When
+ const Button = screen.getByText('하의')
+ userEvent.click(Button)
+ await waitFor(() => {
+ userEvent.click(screen.getAllByText('데님 팬츠')[0])
+ const searchButton = screen.getByText('선택 카테고리 검색하기')
+ userEvent.click(searchButton)
+ // Then
+ expect(FeedData.getState().feedData[0]).toStrictEqual(feed_data[0])
+ })
+ })
+
+ //// 셔츠 선택 후 검색 시 받는 코디 데이터 ////
+ // {
+ // "boardId": 2,
+ // "category": ["후드 집업", "가죽자켓", "컨버스", "운동화", "셔츠"],
+ // "createDate": "2024-02-14T08:00:00.000Z",
+ // "hashTag": ["카페", "행복", "겨울", "과", "가을", "사이"],
+ // "images": {
+ // "boardId": 2,
+ // "imageId": 2,
+ // "imageUrl": "https://i.pinimg.com/564x/18/c0/a6/18c0a61d88e3d75e77039f2de8813f55.jpg"
+ // },
+ // "likeCount": 2,
+ // "likelist": [
+ // {
+ // "likeId": 1,
+ // "nickName": "김첨지"
+ // },
+ // {
+ // "likeId": 2,
+ // "nickName": "lifeis_Happy"
+ // }
+ // ],
+ // "modifiedDate": "2024-02-16T08:00:00.000Z",
+ // "nickName": "smile_",
+ // "temperature": 5.1,
+ // "weatherIcon": "https://openweathermap.org/img/wn/04n.png"
+ // }
+ //// 셔츠 선택 후 검색 시 받는 코디 데이터 ////
+
+ test('셔츠 선택 후 검색 시 맞는 코디를 불러온다', async () => {
+ // Given
+ render()
+ // When
+ const Button = screen.getByText('상의')
+ userEvent.click(Button)
+ await waitFor(() => {
+ userEvent.click(screen.getAllByText('셔츠')[0])
+ const searchButton = screen.getByText('선택 카테고리 검색하기')
+ userEvent.click(searchButton)
+ // Then
+ expect(FeedData.getState().feedData[0]).toStrictEqual(feed_data[1])
+ })
+ })
+ })
+
+ describe('온도 설정 시 온도에 맞는 코디만 불러와진다', () => {
+ test('4도에서 6도 사이의 코디를 불러온다.(feed_data[1])', async () => {
+ // Given
+ render()
+ // When
+ const maxTempInput =
+ screen.getByPlaceholderText('최고온도를 입력해주세요.')
+ const minTempInput =
+ screen.getByPlaceholderText('최저온도를 입력해주세요.')
+ await userEvent.type(minTempInput, '4')
+ await userEvent.type(maxTempInput, '6')
+ await waitFor(() => {
+ const searchButton = screen.getByText('선택 카테고리 검색하기')
+ userEvent.click(searchButton)
+ // Then
+ expect(FeedData.getState().feedData[0]).toStrictEqual(feed_data[1])
+ })
+ })
+
+ test('0도에서 3도 사이의 코디를 불러온다.(feed_data[0])', async () => {
+ // Given
+ render()
+ // When
+ const maxTempInput =
+ screen.getByPlaceholderText('최고온도를 입력해주세요.')
+ const minTempInput =
+ screen.getByPlaceholderText('최저온도를 입력해주세요.')
+ await userEvent.type(minTempInput, '0')
+ await userEvent.type(maxTempInput, '3')
+ await waitFor(() => {
+ const searchButton = screen.getByText('선택 카테고리 검색하기')
+ userEvent.click(searchButton)
+ // Then
+ expect(FeedData.getState().feedData[0]).toStrictEqual(feed_data[0])
+ })
+ })
+ })
+})
diff --git a/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.tsx b/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.tsx
index 2d0de51..9fe14da 100644
--- a/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.tsx
+++ b/weatherfit_refactoring/src/Components/Molecules/post/FeedCategorySelect.tsx
@@ -11,6 +11,19 @@ import { WeatherTempMax } from '@/Store/WeatherMaxTemp'
import { WeatherTempMin } from '@/Store/WeatherMinTemp'
import { CategoryControl } from '@/Store/CategoryControl'
+export const callSearchCategoryData = async (selectData: string[]) => {
+ let url: string = 'https://www.jerneithe.site/board/search?categories='
+ const selectDataToList = selectData.join(',')
+ url += selectDataToList
+
+ console.log(url)
+ const callSearchData = await fetch(url, {
+ method: 'GET',
+ })
+
+ return await callSearchData.json()
+}
+
export default function FeedCategorySelect() {
const { setFeedData } = FeedData()
const { categoryData } = CategoryData()
@@ -81,16 +94,9 @@ export default function FeedCategorySelect() {
const searchCategory = async () => {
console.log('실행', selectData)
- let url: string = 'https://www.jerneithe.site/board/search?categories='
- const selectDataToList = selectData.join(',')
- url += selectDataToList
-
- console.log(url)
- const callSearchData = await fetch(url, {
- method: 'GET',
- })
- const callSearchDataToJson: FEEDDATA[] = await callSearchData.json()
+ const callSearchDataToJson: FEEDDATA[] =
+ await callSearchCategoryData(selectData)
console.log('카테고리 검색 데이터', callSearchDataToJson)