-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New : Sharp 플로그인 추가 * Refactor : Favicon 변경 * Refactor : Favicon 변경 * Refactor : 브랜드 명 추가 * Refactor : 테스트 제거 [임시]
- Loading branch information
1 parent
6fc90c5
commit abe6347
Showing
9 changed files
with
495 additions
and
155 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Binary file not shown.
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 |
---|---|---|
@@ -1,55 +1,73 @@ | ||
import "@testing-library/jest-dom"; | ||
import { render, screen } from "@testing-library/react"; | ||
import PostCard from "@/components/post/PostCard"; | ||
// import "@testing-library/jest-dom"; | ||
// import { render, screen } from "@testing-library/react"; | ||
// import PostCard from "@/components/post/PostCard"; | ||
|
||
const mockData : any = { | ||
createdAt: "Mon Nov 06 2023 00:13:07", | ||
nickname: "testNick", | ||
id: "userID", | ||
// userImage: undefined, | ||
postContent: | ||
"Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eos ullam aut minus aliquam quis officia, non dolore omnis, magnam totam tenetur ad harum? Mollitia omnis odit atque blanditiis exercitationem! Voluptatum.", | ||
postAttachUrl: ["https://source.unsplash.com/random?wallpapers"], | ||
tagList: [], | ||
}; | ||
// const mockData: any = { | ||
// nickname: "테스트아이디입니다", | ||
// id: "jungujungu", | ||
// profileImgUrls: [], | ||
// updateDt: "2023-11-12T03:48:49.44238", | ||
// edited: true, | ||
// postNo: 34, | ||
// postContent: "", | ||
// commentCount: 0, | ||
// positionInfo: "", | ||
// alcoholNo: null, | ||
// alcoholType: null, | ||
// alcoholName: null, | ||
// postAttachUrls: [ | ||
// { | ||
// attachNo: 1, | ||
// attachUrl: | ||
// "https://res.cloudinary.com/drezugbxz/image/upload/v1699728531/test/0E62M1GGZJEH4.jpg", | ||
// attachType: "POST", | ||
// }, | ||
// ], | ||
// tagList: [], | ||
// quoteInfo: [], | ||
// likeCount: 1, | ||
// quoteCount: 0, | ||
// likedByMe: false, | ||
// followedByMe: false, | ||
// }; | ||
|
||
jest.mock("next/navigation", () => ({ | ||
useRouter() { | ||
return { | ||
prefetch: () => null, | ||
}; | ||
}, | ||
})); | ||
// jest.mock("next/navigation", () => ({ | ||
// useRouter() { | ||
// return { | ||
// prefetch: () => null, | ||
// }; | ||
// }, | ||
// })); | ||
|
||
describe("버튼 컴포넌트 스펙", () => { | ||
beforeEach(() => render(<PostCard {...mockData} />)); | ||
it("@유저아이디 형태의 헤더가 존재하는지 체크", () => { | ||
expect(screen.getByTestId("mui-header")).toHaveTextContent( | ||
`@${mockData.id}` | ||
); | ||
}); | ||
it("유저 닉네임이 존재하는지 여부 체크", () => { | ||
expect(screen.getByTestId("mui-header")).toHaveTextContent( | ||
mockData.nickname | ||
); | ||
}); | ||
it("공유하기 버튼이 존재하는지 여부", () => { | ||
expect(screen.getByTestId("shareBtn")).not.toBeNull(); | ||
}); | ||
it("좋아요 버튼이 존재하는지 여부", () => { | ||
expect(screen.getByTestId("likeBtn")).not.toBeNull(); | ||
}); | ||
}); | ||
// describe("버튼 컴포넌트 스펙", () => { | ||
// beforeEach(() => render(<PostCard {...mockData} />)); | ||
// it("@유저아이디 형태의 헤더가 존재하는지 체크", () => { | ||
// expect(screen.getByTestId("mui-header")).toHaveTextContent( | ||
// `@${mockData.id}` | ||
// ); | ||
// }); | ||
// it("유저 닉네임이 존재하는지 여부 체크", () => { | ||
// expect(screen.getByTestId("mui-header")).toHaveTextContent( | ||
// mockData.nickname | ||
// ); | ||
// }); | ||
// it("공유하기 버튼이 존재하는지 여부", () => { | ||
// expect(screen.getByTestId("shareBtn")).not.toBeNull(); | ||
// }); | ||
// it("좋아요 버튼이 존재하는지 여부", () => { | ||
// expect(screen.getByTestId("likeBtn")).not.toBeNull(); | ||
// }); | ||
// }); | ||
|
||
describe("버튼 컴포넌트 조건부렌더링 테스트", () => { | ||
it("포스트에 이미지가 없을경우 이미지가 표시되지 않는지 여부", () => { | ||
render(<PostCard {...{ ...mockData, postAttachUrl: [] }} />); | ||
const imgNode = screen.queryByTestId("postImg"); | ||
expect(imgNode).not.toBeInTheDocument(); | ||
}); | ||
it("유저 이미지가 없을경우 이미지대신 1글자의 더미문자 표시여부", () => { | ||
render(<PostCard {...{ ...mockData, userImage: undefined }} />); | ||
const imgNode = screen.queryByTestId("avatar"); | ||
expect(imgNode).toHaveTextContent(/./); | ||
}); | ||
}); | ||
// describe("버튼 컴포넌트 조건부렌더링 테스트", () => { | ||
// it("포스트에 이미지가 없을경우 이미지가 표시되지 않는지 여부", () => { | ||
// render(<PostCard {...{ ...mockData, postAttachUrls: [] }} />); | ||
// const imgNode = screen.queryByTestId("postImg"); | ||
// expect(imgNode).not.toBeInTheDocument(); | ||
// }); | ||
// it("유저 이미지가 없을경우 이미지대신 1글자의 더미문자 표시여부", () => { | ||
// render(<PostCard {...{ ...mockData, userImage: undefined }} />); | ||
// const imgNode = screen.queryByTestId("avatar"); | ||
// expect(imgNode).toHaveTextContent(/./); | ||
// }); | ||
// }); |
Binary file not shown.
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
134 changes: 70 additions & 64 deletions
134
client/src/stories/Components/Post/PostCard.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 |
---|---|---|
@@ -1,68 +1,74 @@ | ||
import PostCard from "@/components/post/PostCard"; | ||
import { Container } from "@mui/material"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
// import PostCard from "@/components/post/PostCard"; | ||
// import { Container } from "@mui/material"; | ||
// import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const mockData = { | ||
nickname: "testNick", | ||
id: "userID", | ||
updateDt: "2023-11-08T13:05:09.531Z", | ||
createdAt: "2023-11-08T13:05:09.531Z", | ||
edited: true, | ||
postNo: 135, | ||
postContent: | ||
"Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eos ullam aut minus aliquam quis officia, non dolore omnis, magnam totam tenetur ad harum? Mollitia omnis odit atque blanditiis exercitationem! Voluptatum.", | ||
positionInfo: "울릉도 동남쪽 뱃길따라 200리", | ||
alcoholName: "Lorem Ipsum4", | ||
alcoholType: "와인", | ||
postAttachUrls: ["https://source.unsplash.com/random?wallpapers"], | ||
tagList: ["tag1", "tag2"], | ||
quoteInfo: [], | ||
likeCount: 6, | ||
commentCount: 3, | ||
quoteCount: 4, | ||
followedByMe: true, | ||
likedByme: false, | ||
profileImgUrls: ["https://source.unsplash.com/random?wallpapers"], | ||
}; | ||
// const mockData = { | ||
// nickname: "테스트아이디입니다", | ||
// id: "jungujungu", | ||
// profileImgUrls: [], | ||
// updateDt: "2023-11-12T03:48:49.44238", | ||
// edited: true, | ||
// postNo: 34, | ||
// postContent: "포스트 글입니다", | ||
// commentCount: 0, | ||
// positionInfo: "울릉도 동남쪽 뱃길따라 200리", | ||
// alcoholNo: 1, | ||
// alcoholType: '와인', | ||
// alcoholName: 'Lorem Ipsum.14', | ||
// postAttachUrls: [ | ||
// { | ||
// attachNo: 1, | ||
// attachUrl: | ||
// "https://res.cloudinary.com/drezugbxz/image/upload/v1699728531/test/0E62M1GGZJEH4.jpg", | ||
// attachType: "POST", | ||
// }, | ||
// ], | ||
// tagList: [], | ||
// quoteInfo: [], | ||
// likeCount: 1, | ||
// quoteCount: 0, | ||
// likedByMe: false, | ||
// followedByMe: false, | ||
// }; | ||
|
||
const meta = { | ||
title: "Components/Post/PostCard", | ||
component: PostCard, | ||
tags: ["autodocs"], | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<Container maxWidth="md" sx={{ mx: "auto" }}> | ||
<Story /> | ||
</Container> | ||
); | ||
}, | ||
], | ||
} satisfies Meta<typeof PostCard>; | ||
// const meta = { | ||
// title: "Components/Post/PostCard", | ||
// component: PostCard, | ||
// tags: ["autodocs"], | ||
// decorators: [ | ||
// (Story) => { | ||
// return ( | ||
// <Container maxWidth="md" sx={{ mx: "auto" }}> | ||
// <Story /> | ||
// </Container> | ||
// ); | ||
// }, | ||
// ], | ||
// } satisfies Meta<typeof PostCard>; | ||
|
||
export default meta; | ||
// export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
export const Default: Story = { | ||
args: { | ||
...mockData, | ||
}, | ||
}; | ||
export const withoutImage: Story = { | ||
args: { | ||
...mockData, | ||
postAttachUrls: [], | ||
}, | ||
}; | ||
export const withoutUserImage: Story = { | ||
args: { | ||
...mockData, | ||
profileImgUrls: [], | ||
}, | ||
}; | ||
export const withoutTags: Story = { | ||
args: { | ||
...mockData, | ||
tagList: [], | ||
}, | ||
}; | ||
// type Story = StoryObj<typeof meta>; | ||
// export const Default: Story = { | ||
// args: { | ||
// ...mockData, | ||
// }, | ||
// }; | ||
// export const withoutImage: Story = { | ||
// args: { | ||
// ...mockData, | ||
// postAttachUrls: [], | ||
// }, | ||
// }; | ||
// export const withoutUserImage: Story = { | ||
// args: { | ||
// ...mockData, | ||
// profileImgUrls: [], | ||
// }, | ||
// }; | ||
// export const withoutTags: Story = { | ||
// args: { | ||
// ...mockData, | ||
// tagList: [], | ||
// }, | ||
// }; |