-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] 차량 소개, 선착순 이벤트, 인증 모달 관련 테스트 코드 작성 및 리팩토링 #78
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b3ce898
test: 캐러셀 테스트 작성
jw0097 bd04216
test: glow 테스트 코드 수정
jw0097 270f64d
test: InfoScreen에 사용되는 컴포넌트 테스트 작성
jw0097 12395df
test: 폴더 정리 및 Authmodal 테스트 수정
jw0097 e591a8f
test: 선착순 퀴즈 테스트 수정
jw0097 4a16b56
test: 선착순 페이지 테스트 코드 수정
jw0097 46d0317
test: 색상 소개 페이지 테스트 작성
jw0097 dba37f5
test: 드라이브, 편의 정보 테스트 작성
jw0097 4533272
test:외장 소개 테스트 작성
jw0097 1f1d147
test: 내장, 비디오, 퍼포먼스 소개 테스트 작성
jw0097 9d8e52d
refactor: console 제거
jw0097 d9b8991
Merge branch 'develop' into feature/test-refactor
leve68 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from "react"; | ||
import App from "./App"; | ||
test("App", () => { | ||
const a = 1; | ||
expect(a).toBe(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from "react"; | ||
import { outsideInfoData } from "../../../constants/InfoData"; | ||
import { render, screen } from "../../../utils/TestUtils"; | ||
import OutsideDescriptionItem from "../../mainPage/InfoScreen/OutsideDescriptionItem/OutsideDescriptionItem"; | ||
import Carousel from "./Carousel"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
const carouselItems = outsideInfoData.map(({ key, title, content, image }) => { | ||
return ( | ||
<OutsideDescriptionItem | ||
key={key} | ||
title={title} | ||
description={content} | ||
img={image} | ||
/> | ||
); | ||
}); | ||
|
||
const onClickCase = Array.from({ length: outsideInfoData.length }, (_, i) => i); | ||
|
||
describe("Carousel Component", () => { | ||
beforeEach(() => { | ||
IntersectionObserver = jest.fn().mockImplementation((callback) => ({ | ||
observe: jest.fn((element) => { | ||
callback([ | ||
{ isIntersecting: false, target: element }, | ||
{ isIntersecting: true, target: element }, | ||
{ isIntersecting: false, target: element }, | ||
]); | ||
}), | ||
unobserve: jest.fn(), | ||
disconnect: jest.fn(), | ||
})); | ||
|
||
Element.prototype.scrollTo = jest.fn(); | ||
}); | ||
|
||
test("props로 전달받은 아이템 숫자 만큼의 하위 요소를 렌더링 해야 한다.", () => { | ||
render(<Carousel items={carouselItems} />); | ||
|
||
const items = screen.getAllByRole("img"); | ||
expect(items.length).toBe(outsideInfoData.length); | ||
}); | ||
|
||
onClickCase.forEach((index) => { | ||
test(`props로 ${index}번 째 아이템을 누르면 ${index}번 째 요소로 스크롤 되고, 투명도가 100이 되어야 한다.`, async () => { | ||
render(<Carousel items={carouselItems} />); | ||
|
||
const items = screen.getAllByRole("img"); | ||
await userEvent.click(items[index]); | ||
|
||
const carouselContainer = items[index].parentElement; | ||
const targetPosition = | ||
items[index].offsetLeft - carouselContainer!.offsetLeft; | ||
|
||
expect(carouselContainer?.scrollTo).toHaveBeenCalledWith({ | ||
top: 0, | ||
left: targetPosition, | ||
behavior: "smooth", | ||
}); | ||
|
||
expect(items[index].parentElement?.parentElement).toHaveClass( | ||
"opacity-100", | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...nts/mainPage/InfoScreen/ConvenienceDescriptionItem/ConvenienceDescriptionItem.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
import ConvenienceDescriptionItem from "./ConvenienceDescriptionItem"; | ||
import { convenienceInfoData } from "../../../../constants/InfoData"; | ||
|
||
export default { | ||
component: ConvenienceDescriptionItem, | ||
title: "main/Info/ConvenienceDescriptionItem", | ||
tags: ["autodocs"], | ||
excludeStories: /.*Data$/, | ||
}; | ||
|
||
export const Main = { | ||
args: { | ||
title: convenienceInfoData[0].title, | ||
description: convenienceInfoData[0].description, | ||
img: convenienceInfoData[0].image, | ||
}, | ||
}; |
32 changes: 32 additions & 0 deletions
32
...onents/mainPage/InfoScreen/ConvenienceDescriptionItem/ConvenienceDescriptionItem.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { render, screen } from "../../../../utils/TestUtils"; | ||
import { convenienceInfoData } from "../../../../constants/InfoData"; | ||
import ConvenienceDescriptionItem from "./ConvenienceDescriptionItem"; | ||
const defaultProps = { | ||
title: convenienceInfoData[0].title, | ||
description: convenienceInfoData[0].description, | ||
img: convenienceInfoData[0].image, | ||
}; | ||
|
||
describe("ConvenienceDescriptionItem 렌더링 테스트", () => { | ||
test("props로 전달받은 제목이 렌더링 되야 한다.", () => { | ||
render(<ConvenienceDescriptionItem {...defaultProps} />); | ||
|
||
const title = screen.getByText(defaultProps.title); | ||
expect(title).toBeInTheDocument(); | ||
}); | ||
|
||
test("props로 전달받은 설명이 렌더링 되야 한다.", () => { | ||
render(<ConvenienceDescriptionItem {...defaultProps} />); | ||
|
||
const description = screen.getByText(defaultProps.description); | ||
expect(description).toBeInTheDocument(); | ||
}); | ||
|
||
test("props로 전달받은 이미지가 렌더링 되야 한다.", () => { | ||
render(<ConvenienceDescriptionItem {...defaultProps} />); | ||
|
||
const image = screen.getByRole("img"); | ||
expect(image).toHaveAttribute("src", defaultProps.img); | ||
}); | ||
}); | ||
Comment on lines
+11
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 props 에 따른 랜더링테스트 test 하나에서 전부 했는데 랜더링 테스트를 분리해서 하나의 describe 에 넣는 방식도 좋은 것 같아요 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/components/mainPage/InfoScreen/DriveDescriptionItem/DriveDescriptionItem.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import DriveDescriptionItem from "./DriveDescriptionItem"; | ||
import { driveInfoData } from "../../../../constants/InfoData"; | ||
|
||
export default { | ||
component: DriveDescriptionItem, | ||
title: "main/Info/DriveDescriptionItem", | ||
tags: ["autodocs"], | ||
excludeStories: /.*Data$/, | ||
}; | ||
|
||
export const Main = { | ||
args: { | ||
title: driveInfoData[0].title, | ||
img: driveInfoData[0].image, | ||
}, | ||
}; |
24 changes: 24 additions & 0 deletions
24
src/components/mainPage/InfoScreen/DriveDescriptionItem/DriveDescriptionItem.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import { render, screen } from "../../../../utils/TestUtils"; | ||
import { driveInfoData } from "../../../../constants/InfoData"; | ||
import DriveDescriptionItem from "./DriveDescriptionItem"; | ||
const defaultProps = { | ||
title: driveInfoData[0].title, | ||
img: driveInfoData[0].image, | ||
}; | ||
|
||
describe("DriveDescriptionItem 렌더링 테스트", () => { | ||
test("props로 전달받은 제목이 렌더링 되야 한다.", () => { | ||
render(<DriveDescriptionItem {...defaultProps} />); | ||
|
||
const title = screen.getByText(defaultProps.title); | ||
expect(title).toBeInTheDocument(); | ||
}); | ||
|
||
test("props로 전달받은 이미지가 렌더링 되야 한다.", () => { | ||
render(<DriveDescriptionItem {...defaultProps} />); | ||
|
||
const image = screen.getByRole("img"); | ||
expect(image).toHaveAttribute("src", defaultProps.img); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/components/mainPage/InfoScreen/OutsideDescriptionItem/OutsideDescriptionItem.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
import OutsideDescriptionItem from "./OutsideDescriptionItem"; | ||
import { outsideInfoData } from "../../../../constants/InfoData"; | ||
|
||
export default { | ||
component: OutsideDescriptionItem, | ||
title: "main/Info/OutsideDescriptionItem", | ||
tags: ["autodocs"], | ||
excludeStories: /.*Data$/, | ||
}; | ||
|
||
export const Main = { | ||
args: { | ||
title: outsideInfoData[0].title, | ||
description: outsideInfoData[0].content, | ||
img: outsideInfoData[0].image, | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/components/mainPage/InfoScreen/OutsideDescriptionItem/OutsideDescriptionItem.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import { render, screen } from "../../../../utils/TestUtils"; | ||
import { outsideInfoData } from "../../../../constants/InfoData"; | ||
import OutsideDescriptionItem from "./OutsideDescriptionItem"; | ||
const defaultProps = { | ||
title: outsideInfoData[0].title, | ||
description: outsideInfoData[0].content, | ||
img: outsideInfoData[0].image, | ||
}; | ||
|
||
describe("OutsideDescriptionItem 렌더링 테스트", () => { | ||
test("props로 전달받은 제목이 렌더링 되야 한다.", () => { | ||
render(<OutsideDescriptionItem {...defaultProps} />); | ||
|
||
const title = screen.getByText(defaultProps.title); | ||
expect(title).toBeInTheDocument(); | ||
}); | ||
|
||
test("props로 전달받은 이미지가 렌더링 되야 한다.", () => { | ||
render(<OutsideDescriptionItem {...defaultProps} />); | ||
|
||
const image = screen.getByRole("img"); | ||
expect(image).toHaveAttribute("src", defaultProps.img); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 훅 자체를 그냥 목 으로 사용했는데 이렇게 하면 구체적으로 어떤 애니메이션을 호출해서 실행했는지까지도 테스트 할 수 있겠네요